go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Build from the top level container
 
Subject: Build from the top level container
Author: Linux
In response to: The sub-level project -- app module
Posted on: 10/31/2017 05:34:31 AM


$ cd /opt/maven/hello-one
$ mvn package


The output:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] hello-one-pom
[INFO] util-jar
[INFO] app-jar
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hello-one-pom 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building util-jar 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ util-jar ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /opt/maven/hello-one/util/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ util-jar ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ util-jar ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /opt/maven/hello-one/util/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ util-jar ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ util-jar ---
[INFO] Surefire report directory: /opt/maven/hello-one/util/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.xyz.commons.DateUtilTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.231 sec

Results :

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

[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ util-jar ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building app-jar 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ app-jar ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /opt/maven/hello-one/app/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ app-jar ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ app-jar ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /opt/maven/hello-one/app/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ app-jar ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ app-jar ---
[INFO] Surefire report directory: /opt/maven/hello-one/app/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.xyz.integration.HelloTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.119 sec

Results :

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

[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ app-jar ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] hello-one-pom ...................................... SUCCESS [  0.014 s]
[INFO] util-jar ........................................... SUCCESS [  3.746 s]
[INFO] app-jar ............................................ SUCCESS [  0.631 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.647 s
[INFO] Finished at: 2017-10-30T22:28:33-07:00
[INFO] Final Memory: 10M/60M
[INFO] ------------------------------------------------------------------------


 

> On 10/31/2017 05:25:18 AM Linux wrote:


The source code:
$ nano /opt/maven/hello-one/app/src/main/java/com/xyz/integration/Hello.java


package com.xyz.integration;

import com.xyz.commons.*;

public class Hello {

        String name = "World"; // default

        public Hello(){
        }

        public Hello(String name){
            this.name = name;
        }
        
        public String getName() {
            return name;
        }

        public String getGreetings() {
            return "Hello " + getName() + "!";
        } 

        public static void main(String[] args) {
            Hello hello = new Hello("World");
            String msg = hello.getGreetings() + " Today is " + DateUtil.getToday();
            System.out.println(msg);
        }

}


The test code:
$ nano /opt/maven/hello-one/app/src/test/java/com/xyz/integration/HelloTest.java


package com.xyz.integration;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class HelloTest {

        @Test
        public void testGetName() {
                String actual = new Hello("World").getName();
                String expected = "World";
                assertEquals(expected, actual);
        }

        @Test
        public void testGetGreetings() {
                String actual = new Hello().getGreetings();
                String expected = new Hello("World").getGreetings();
                assertEquals(expected, actual);
        }
}


pom.xml
$ nano /opt/maven/hello-one/app/pom.xml


<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>

        <!-- parent coordinates -->
        <parent>
            <groupId>com.xyz</groupId>
            <artifactId>hello-one-pom</artifactId>
            <version>1.0</version>
        </parent>

        <!-- project coordinates -->
        <groupId>com.xyz</groupId>
        <artifactId>app-jar</artifactId>
        <version>1.0</version>

        <packaging>jar</packaging>

        <!-- project dependencies -->
        <dependencies>

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

            <dependency>
                <groupId>com.xyz</groupId>
                <artifactId>util-jar</artifactId>
                <version>1.0</version>
            </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.