Eclipse Juno m2ecliipse : directory structure explanation - maven

I'm working under Eclipse Juno on a maven-archetype-webapp project done with m2eclipse.
I don't understand directory structure. Anyone could explain how it's working?
Thanks
What i src/main/ressources for ? When you create package, it's not showed as package but only directory.
I create a /src/main/java package and it's where i put my classes. The package structure hierarchy is ok.
What is librairies ressources? Is it where you put javascript jquery? but when i put jquery plugin it does a lot of effor in the project manager. And i want my javascript under /webapp/javascript... What is ECMAScript Library ? What to do with that, what is for?
Same question about Deployed Ressources and target and Jax-WS Web Services ?
Ok target must be the directory when you build the project maven, but i can't see the war file. When you run build how to configure it in eclipse to generate the build? What is the command ?
Thanks , i know it's a lot of questions but i'm beginner !
Have a great day :)
I just add the example when you put jquery in webapp

All of this is explained here.
src/main/java This is where your source code goes
src/main/resources This is where you put your resources like your xml files. Things that aren't java classes but need to be in your classpath. If you put them under /java, they won't be copied into your classpath so you have to put them here.
src/main/webapp This is for webapps. Everything you put in here will be copied over to your war file, directly.

Related

Classpath root pointing to grails-app/views - how to amend?

My goal is to add some Json files as project resources accessible from the code. The solution must work in IntelliJ and deployed in a Tomcat. I don't mind if the files are located under grails-app/conf or src.
Getting my classpath root using one of
grailsApplication.parentContext.getResource("classpath:") or
grailsApplication.parentContext.getResource("classpath:.")
resolves in $MY_APP/grails-app/views
However, trying to navigate from this root to grails-app/src using
grailsApplication.parentContext.getResource("classpath:..")
results in: "java.io.FileNotFoundException: class path resource [..] cannot be resolved to URL because it does not exist". This might be acceptable since a root is a root, I guess.
How can I extend my classpath to folders outside of grails-app/views?
How can I make sure that the solution works in both, IntelliJ and Tomcat deployment?
I'm using Gradle 3.5, Grails 3.3.11, Groovy 2.4.10. I'm working in IntelliJ. Rebuilding the project using the Gradle view has not helped so far. The project setup consists of
grails-app/conf/application.yml
grails-app/conf/application.groovy
grails-app/conf/ApplicationResources.groovy (I've tried to add a resource entry here and rebuild the project)
... (Please feel free to have a look in the project in case of further config detail questions.)
I've been exploring endless questions and answers of similar "how can I add my file to the classpath" questions, but nothing has helped so far.
As mentioned earlier in the comment, that you should put the JSON files under /src/main/resources folder. And, you should be able to access the files as:
getClass().getResource("/example.json")
Here is an example application
#PuneetBehl's answer helped me realizing that it isn't about the project code configuration. It is about the configuration of my IDE, which is IntelliJ. You can set Project Structure... --> Project Settings --> Modules. There, "Resource Folders" on the right hand side was listing as: "conf", "i18n" and "views". I dont know why IntelliJ chose "views" for the path "/.".
Anyway, it was enough to:
use Puneet's proposed syntax: getClass().getResource("/myfolder/example.json")
after I had created grails-app/conf/myfolder/example.json

Why servlets can be created only under the resources folder?

I'm trying to develop a new java web application from scratch. I'm using the IntelliJ IDE, and maven build tool.
Why servlets can be created only under the resources folder ?
Why jsp filels can be created only under the webapp folder?
Thanks
Sounds like you need to do some research into how Maven is building your project.
You should create servlets under src/main/java folder.
Run the maven build and then explore the generated WAR file, this way you can get an idea of how Maven is structuring the project.
You should see the that the webapp folder is in fact simply deployed at the root of the WAR file, hence your JSPs are placed in the correct location.
Thanks everybody, but i resolved the issue myself.
The Solution:
Go to the folder which you want to make available for java classes or servlets, and right click it.
Choose: Mark directory as...
Choose: Sources Root

How to point Maven IDEA plugin what type of module to generate?

I have a project that consists of several modules (app. 10-12). I use maven idea plugin to generate .iml for each module, but I have one problem. All modules are of JAVA_MODULE type, but plugin generates main module as J2EE_WEB_MODULE. I think it is because there's .war files and WEB_INF folders in target folder, but these ones are for Tomcat usage. Anyway, at the end I must edit .iml file and change J2EE_WEB_MODULE to JAVA_MODULE.
Is there any way to make maven plugin generate a module of specific type? Or maybe there's a workaround that lets one change with maven, using regexp, module type in .iml?
Thank you in advance.
Do not use the maven-idea-plugin, it is obsolete and has not been updated since 2008.
Just open the project by pointing to the pom.xml.
The guys at JetBrains has done a perfect job with their own maven integration.

Adding existing source packages to a Maven Web Application in Netbeans

I have a normal Netbeans project, and I would like to add the source packages of this project to a project that is a Maven Web Application, also within Netbeans.
I tried copy-pasting the packages into the /src project directory of the Maven application, but this doesn't seem to work.
Could someone please tell me how I could do this ?
If this is not possible, could someone tell me if I can convert the entire normal project into a Maven Web Application ? Thank you :)
It sounds like you need to add the dependency to your web-application instead of the source code, cause maven is intended to handle exactly such situations.

Maven: where to store examples source code?

Currently I'm working on open source project.
There exists bunch of java classes which are simple examples.
How should I organize this project with maven. Should I provide some packaging for them ?
Put the examples in a separate project and add your main project as a dependency. Package them according to what kind of code they are. (e.g. if the samples build a webapp, make the packaging a war)

Resources