Is there a possibility or a workaroud to use maven-archetype-webapp archetype to generate a maven webapp with plain directory structure like
/src
/main
/java
/resources
/webapp
/test
/java
/resources
I assume that your issue is the missing java and test folders in a new project when using maven-archetype-webapp. There are no options to make that archetype to add those. Of course you could add them manually after the project was created.
You may find another archetypes in one of these lists:
http://myjeeva.com/exclusive-maven-archetype-list.html
http://docs.codehaus.org/display/MAVENUSER/Archetypes+List
If there is nothing that matches what you need I suggest creating an own archetype: http://maven.apache.org/guides/mini/guide-creating-archetypes.html
It is quite easy and if you plan to use one several times it's probably worth the effort.
Actually I am not very sure of what you are asking, I mean are you looking for an alternative solution to maven-archetype-webapp ?
With maven archetype you can create the above mentioned directory structure without any hassle, of course java and test folders will be missing there.
mvn archetype:generate -DgroupId=com.techidiocy -DartifactId=FirstWeb
-DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
2) If you are using eclipse IDE , then you can issue the command mentioned below to convert your maven project into an Eclipse Web Project.
mvn eclipse:eclipse -Dwtpversion=2.0
This Step 2 is optional , if you are not planning to bind it with eclipse
Thanks
Related
I am trying to mavenize an Ant project (web application) with Eclipse.
To do so I tried the "easy" way :
Right click on the project → Configure → Convert to Maven
Then I added the dependencies (the pom file looks fine and I don't have dependencies issues)
The build (clean install) is successful and generates a war file but I can't deploy it in Tomcat.
I noticed that there were differences between the war file generated by the Ant project (38 000 lines) and the one generated from the Maven project (27 000 lines). It seems that some parts are missing (for example the css part of the code).
I was thinking maybe this is because the project doesn't have a "real" Maven structure as it has the Ant one.
So I tried to create a Maven project in Eclipse and then add the files to it (src goes to src/main/java, etc.). Regarding this I am not sure where to put the web folder.
I tried different ways but nothing works.
How should I proceed?
The standard location for webapps in maven is src/main/webapp. Just move the contents of your web folder there, and you should be fine.
I am a maven newbie. My project depends on another maven project (ProjectA) in that I need to run mvn clean package on ProjectA which gives me JarA.
Then, I need to run java JarA feeding it with an xml configuration file which gives me another JarB. I need both JarA and JarB as dependencies on my project (ProjectB).
Any comments on whether it is possible to achieve these steps in projectB's pom file? Would having parent-submodule type of a configuration help? Thanks!
Maybe. The most simple solution to get JarB would be to add a unit test to project A. But that doesn't tell Maven about this JAR, so it will ignore it.
The next step would be to get the test to write JarB as JarA-config into the target/ folder of project A. Maven supports multiple artifacts as "build results". You can then use the "qualifier" to distinguish between them.
Use build-helper:attach-artifact to tell Maven about the second JAR. See "Attach additional artifacts to your project" for an example.
Note that package happens after test, so your test case can create the second JAR and build-helper will then find it.
In project B, you can then use this to depend on both JARs
<dependency>
<groupId>x</groupId>
<artifactId>jarA</artifactId>
</dependency>
<dependency>
<groupId>x</groupId>
<artifactId>jarA</artifactId>
<classifier>config</classifier>
</dependency>
Note the additional <classifier> element.
Note: For this to work, you need to run mvn install in project A.
Is it possible to combine the capabilities of an archetype and a normal Maven plugin into a single plugin?
I have a custom language which I can compile into Java source code. I've written a Maven plugin which does this in the generate-sources phase, adds the Java source to the project, and builds the project. It works as I'd expect.
However, to use it, I need to first write out a pom.xml file referencing my plugin and describing where the input files live. I'd like to be able to go straight from raw input files to compiled code in a single maven command.
For example, suppose I have this directory structure:
my-project/
some-input-file.dsl
I want to run
bash$ mvn com.waisbrot.plugin:generate -DgroupID=com.waisbrot package
and after Maven's done running have:
my-project/
some-input-file.dsl
pom.xml
target/
generated-sources/
plugin/
SomeInputFile.java
classes/
com/
waisbrot/
SomeInputFile.class
some-input-file-1.0.jar
Actually, the integration testing of the archetype allows you to declare the parameter and goals. So do this:
Pick the template project you want to create
mvn archetype:create-from-project. It will create a new archetype
Review src/test/resources/projects, especially goal.txt and archetype.properties (source: http://maven.apache.org/archetype/maven-archetype-plugin/integration-test-mojo.html). Tweak so install will be implicity
mvn verify will be able to build the archetype, run the it, and get it installed
Hope it helps
I am trying to move my MyEclipes projects to maven. But of course there are problems. After creating a web priject I get missing jar files - about 5
org.springframework.security jar files e.g. org.springframework.security.ldap-3.0.5.RELEASE
show as missing in the jar build path. They are not in the corresponding .m2 directory. I un-installed ME4S, and deleted .m2, which force .me to be rebuilt on re-install, but it has the same problem.
How do I fix this?
It would be very helpful to understand how the .m2 process works - where is this coming from and how is it controlled?
I am not sure about the MyEclipse part, but this seems to be a pure maven question.
Maven (2/3) uses the pom.xml. This file describe your project. In that file you should define a list of dependencies (which can have their own dependencies and so on).
Maven read the pom.xml and build the classpath accordingly using direct and transitive dependencies.
You can use the mvn dependency:tree command to see how your classpath is built.
More on the plugin page
I'm building a maven archetype project. As parameter (serviceDescriptor), I'm passing path to an xml file. When the generate goal is successfully executed, I would like to have the serviceDescriptor file in src/main/resources. Based on maven archetype documentation, it seems that is not possible but, there should be a way to do it.
I have spent couple of days on this and I think that I have found a reasonable solution.
As I mention in the question, I'm passing the file path as required property to the archetype:generate.
I had to implement a simple plug-in that is executed after archetype generate is finishing. This plug-in is coping the file into src/main/resources, read some data from the file and update the pom.xml setting some properties. In order to be able to modify the pom.xml file I'm using maven-model-2.0 archetype as dependency in maven plug-in. It offers Maven MvenXpp3Reader and MavenXpp3Writer classes that allows to safe modify pom.xml.
In order to tell to archetype project to execute plug-in at the end of generate phase of archetype:
mvn archetype:generate -goals=plugin_groupId:plugin_artifactId:goal
The downside is that the plug-in should be available in a accessible repository or local repo.