go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Build Java project
 
Subject: Build Java project
Author: Alex_Raj
In response to: Create Java Project with Maven
Posted on: 03/26/2012 12:10:57 AM

With the pom.xml file being available, you can build your Java project's package (jar) by:

mvn package


The output is as follows:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ MyProject
---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\HelloWorld\Maven\MyProject\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ MyProject ---

[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 1 source file to C:\HelloWorld\Maven\MyProject\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ My
Project ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\HelloWorld\Maven\MyProject\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ MyPro
ject ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 1 source file to C:\HelloWorld\Maven\MyProject\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ MyProject ---
[INFO] Surefire report directory: C:\HelloWorld\Maven\MyProject\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.mycompany.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.026 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ MyProject ---
[INFO] Building jar: C:\HelloWorld\Maven\MyProject\target\MyProj
ect-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.248s
[INFO] Finished at: Sun Mar 25 21:55:38 PDT 2012
[INFO] Final Memory: 10M/121M
[INFO] ------------------------------------------------------------------------


 

> On 03/25/2012 11:38:45 PM Alex_Raj wrote:

On console, type in the following command:

mvn archetype:generate -DgroupId=com.mycompany -DartifactId=MyProject 
  -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false


where two parameters needs be specified:
-DgroupId=com.mycompany
-DartifactId=MyProject


The output is as follows:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>
>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<
<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom --
-
[INFO] Generating project in Batch mode
[INFO] -------------------------------------------------------------------------
---
[INFO] Using following parameters for creating project from Old (1.x) Archetype:
 maven-archetype-quickstart:1.0
[INFO] -------------------------------------------------------------------------
---
[INFO] Parameter: groupId, Value: com.mycompany
[INFO] Parameter: packageName, Value: com.mycompany
[INFO] Parameter: package, Value: com.mycompany
[INFO] Parameter: artifactId, Value: MyProject
[INFO] Parameter: basedir, Value: C:\HelloWorld\Maven
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:\HelloWorld\Maven\MyProject
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.429s
[INFO] Finished at: Sun Mar 25 14:53:31 PDT 2012
[INFO] Final Memory: 8M/121M
[INFO] ------------------------------------------------------------------------


The generated Maven project is of the following structure:
 [+] -- MyProject
     [-] -- pom.xml
     [+] -- src
         [+] -- main
             [+] -- java
                 [+] -- com
                     [+] -- mycomany
                         [-] -- App.java
         [+] -- test
             [+] -- java
                 [+] -- com
                     [+] -- mycomany
                         [-] -- AppTest.java



The content of pom.xml is as follows:

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
     http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany</groupId>
  <artifactId>MyProject</artifactId>

  <packaging>jar</packaging>

  <version>1.0-SNAPSHOT</version>
  <name>MyProject</name>

  <url>http://maven.apache.org</url>

  <dependencies>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

</project>





References:

 


 
Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.