go to  ForumEasy.com   
JavaPro
Home » Archive » Message


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


The source code:

$ nano /opt/maven/hello-one/util/src/main/java/com/xyz/commons/DateUtil.java


package com.xyz.commons;

import java.util.Date;
import org.apache.commons.lang.time.DateFormatUtils; // the third party class

public class DateUtil {
        public static String getToday() {
                String today = DateFormatUtils.format(new Date(), "dd-MMM-yyyy");
                return today;
        }
}


The test code:
$ nano /opt/maven/hello-one/util/src/test/java/com/xyz/commons/DateUtilTest.java


package com.xyz.commons;

import static org.junit.Assert.assertEquals;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.junit.Test;

public class DateUtilTest {

        @Test
        public void testGetToday() {
                String actual = DateUtil.getToday();
                String expected = new SimpleDateFormat("dd-MMM-yyyy")
                                .format(new Date());
                assertEquals(expected, actual);
        }
}


pom.xml
$ nano /opt/maven/hello-one/util/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>util-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>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>2.4</version>
            </dependency>

        </dependencies>
</project>


 

> On 10/31/2017 05:21:36 AM Linux wrote:


The top-level project is just a container consisting of modules and a pom.xml file

$ nano /opt/maven/hello-one/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>

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

        <packaging>pom</packaging>

        <modules>
                <module>app</module>
                <module>util</module>
        </modules>

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