Now I created a Maven Project : File -> New -> Other -> Maven -> Maven Project -> Next -> Which group ID and artifact ID do I choose ?
Carles Gasques wrote:Hi,
Now I created a Maven Project : File -> New -> Other -> Maven -> Maven Project -> Next -> Which group ID and artifact ID do I choose ?
Eclipse -> File -> New -> Other -> Maven -> Maven Project -> Next ->
Then you could select and archetype, set filter to 'web' and select 'maven-archetype-webapp', click next.
Now set group id "my-webapp", artifact id "my-webapp-test" and package "my.webapp.test".
You are done, browse your maven webapp project.
Click your project / run / run as / click maven build / click on new launch configuration (icon with a sheet +) / select your maven project as base directory and set goal as package / run
Now you have your project packaged as a war in the target directory.
Best regards
Peter Johnson wrote:The other possibility is to ignore the various archetypes and instead go with a simple Maven project (the top checkbox) on the first page New Maven Project dialog, then on the next page choose "war" in the packaging dropdown. That will give you a basic WAR project.
What you use for GroupId and ProjectId is up to you. You really need to examine how others have set these up. The groupId usually matches the basic package name for the classes in the project. For example, you can find groupIds that start with "org.apache", "org.jboss", etc.
For the projectId, use the name that you want to give to your WAR file. That name will also be the name used for the project directory in the Eclipse workspace.
It might help if you went through a simple Maven tutorial for building a web application. You can find on in chapter 4 of Better Builds with Maven (http://www.maestrodev.com/support/)
Peter Johnson wrote:1) Yes. Place your servlet and related Java sources in src/main/java. Maven will automatically include the compiled class files in WEB-INF/classes in the WAR file. You do not need to do anything special in the POM to get this behavior.
2) There is a Maven plugin for JBoss AS 7 that will do this for you. See http://docs.jboss.org/jbossas/7/plugins/maven/7.4.Final/
TIP
Maven is an extreme example of the principle of “inversion of control.” The key to success with Maven is to work with it, not against it. This is best achieved by avoiding trying to change how Maven does things. Rather, it is best to find out the way Maven intends to do the sort of thing you want and then provide input to that process.
All of the action in Maven happens on top of the backbone of the build lifecycle. All of the work done by Maven during a build is done by plugins executing at specific phases during the build lifecycle. Each specific thing that a plugin does is called a “goal.” Plugins typically declare in which lifecycle phases their goals are designed to execute. There are actually three lifecycles that are used in Maven, called clean, default, and site. Every invocation of mvn will use at least one of these three lifecycles. When analyzing its command-line arguments, Maven determines which of the three lifecycles to run and the end phase for each one, based on the order in which the arguments are specified. The clean and site lifecycles deal with running the clean and site goals. Clean resets the project to its nonbuilt state, usually just deleting the target directory. Site generates reports, such as code coverage and unit test results. The default lifecycle is the most interesting and is where most of the work is done by Maven and its many plugins. Hudson jobs that invoke Maven will usually have cause to use all of these different lifecycles in one way or another.
Each of the three lifecycles consists of several different phases, each with a name and purpose and executed in sequence by Maven. Maven always executes at least one of the three lifecycles, and when it does, it always executes them from the start phase until the user-specified end phase. You can think of the execution of the lifecycle phases as a journey on a non-express train from the starting station through multiple stations. When traveling on a such a train from the starting station, you can get off at any station, but no stations can be skipped.
Ed Burns wrote:Because mastery of Maven is essential to effectively using Hudson, we cover Maven extensively in our book, "Hudson Continuous Integration in Practice". Here is a little excerpt from Chapter 5: Hudson and Automated Testing.
[OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Everybody! Do the Funky Monkey! Like this tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
|