Gibbs
Gibbs

Reputation: 22964

Maven creating quickstart template

I am learning maven. I just installed maven.

mvn -version

says

Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T23:07:52+05:30)
Maven home: C:\Users\gopir\Documents\MyJabberFiles\[email protected]\apache-maven-3.2.1-bin\apache-maven-3.2.1\bin\..
Java version: 1.7.0_71, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_71\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

I tried to create a project with the help of

 mvn -e archetype:generate -DgroupId=x:y -DartifactId=testMaven -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

I am getting the following error

 Failed to execute goal org.apache.maven.plugins:maven-archetype-\     
 plugin:2.3:generate (default-cli) on project standalone-pom: Error merging 
 velocity templates -> [Help 1]
 he.maven.lifecycle.LifecycleExecutionException: Failed to execute goal 
 org.apache.maven.plugins:maven-archetype-plugin:2.3:generate (default-cli) 
 on project standalone-pom: Error merging velocity templa...

Is it default one? What should i change to get my pom.xml and other directories?

Thanks

Upvotes: 2

Views: 2187

Answers (3)

Nirmal
Nirmal

Reputation: 1259

I will list here the steps that I use on a regular basis(as of today). You can compare your steps and see where you need change. The relative paths are shown for Mac / OSX. Which isn't different, conceptually, than windows.

All of the commands in the following are to be run on terminal.

  1. cd into workspace or mkdir for project folder /Users/ProjectFolder

  2. run the following command mvn archetype:generate -DgroupId=com.folder.name.you.like -DartifactId=NameOfProject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

  3. cd into the folder named as artifactID and run mvn eclipse:eclipse

  4. File->import->Select Existing Project Into Workspace the project in eclipse as existing project and give the path to the artifactId from above. Check to make sure you have the pom.xml in the eclipse project once the import succeeds.

  5. Add the following plugin for maven compiler in pom.xml (this is for java 1.8)

     <build>
        <plugins>
            <plugin> 
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
  1. Add source files to the project in eclipse run the following command from the same present directory (as in #3 above) mvn package

Upvotes: 2

alainlompo
alainlompo

Reputation: 4434

Something else that could help you. If you type mvn archetype:generate on the command line it will enter in an interactive mode and will list a big bunch of maven archetypes for you (I see more than 1300 templates in my cmd) and will prompt you to enter the number of one of them. Them it will lead you step by step (in an interactive fashion) into creating your project on the basis of the chosen template.

list of archetypes

Upvotes: 0

TSKSwamy
TSKSwamy

Reputation: 225

To create a maven quick start project use the following command.

mvn archetype:generate -DgroupId=com.testpackage
   -DartifactId=DemoProject
   -DarchetypeArtifactId=maven-archetype-quickstart 
   -DinteractiveMode=false

Refer: How to create a Java Project with Maven

Upvotes: 3

Related Questions