I'm converting in maven an old project that originally rely on eclipse and ant to build.
Stated that I can't chancge the directory layout of that project, I would like to produce some artifact similar to ones build with that ant script. The original project, build all classes with from subprojects in one directory with eclipse, then package the resulting classes with ant in subpackages (different from subprojects).
To deal with this requirements I've done the following structure: (as now only one of the subpackage)
warp-parent
|
|- pom.xml
|- warp-client
| |
| | - pom.xml
the parent pom is the following:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.sinesy.warp</groupId>
<artifactId>warp-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>warp-parent</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>../../src</source>
<source>../../srcj2ee</source>
<source>../../srcjsf</source>
<source>../../srcrest</source>
<source>../../srcswing</source>
<source>../../srctest</source>
<source>../../srcweb</source>
<source>../../srcws</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
</dependencies>
<modules>
<module>warp-client</module>
</modules>
</project>
and the child one:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>it.sinesy.warp</groupId>
<artifactId>warp-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>it.sinesy.warp</groupId>
<artifactId>warp-client</artifactId>
<version>1.0-SNAPSHOT</version>
<name>warp-client</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<includes>
<include>**</include>
<!--
<include>**/it/tinet/warp/swing/**/java/*</include>
<include>**/it/tinet/warp/common/**/java/*</include>
<include>**/it/tinet/warp/swing/**/client/*</include> -->
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
</dependencies>
</project>
When I try to compile to compile the parent pom I got the following output, with no source compiled:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] warp-parent
[INFO] warp-client
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building warp-parent 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) # warp-parent ---
[INFO] Source directory: /home/elettronik/test/warp/warp_src/src added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcj2ee added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcjsf added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcrest added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcswing added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srctest added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcweb added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/srcws added.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building warp-client 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) # warp-client ---
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/src added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcj2ee added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcjsf added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcrest added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcswing added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srctest added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcweb added.
[INFO] Source directory: /home/elettronik/test/warp/warp_src/mvn/srcws added.
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # warp-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/elettronik/test/warp/warp_src/mvn/warp-parent/warp-client/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # warp-client ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] warp-parent ....................................... SUCCESS [0.762s]
[INFO] warp-client ....................................... SUCCESS [1.389s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.389s
[INFO] Finished at: Fri Aug 16 14:03:32 CEST 2013
[INFO] Final Memory: 6M/109M
[INFO] ------------------------------------------------------------------------
Could someone give some advice to make this work? thanks to all.
Your parent-pom shows <packaging>pom</packaging> so the sources you define in the parent pom will not be compiled.
Related
I want to build a multi-modules SpringBoot app with following modules :
App : the Parent module, Main class is here
Model : all Domain objects, no Main class, no tests
Tests : dedicated to whole app tests, will have Cucumber tests
My problem is :
I actually can run unit tests on Model's objects in Tests module, but doing a mvn clean install on App module fails because Tests module doesn't know anything about Model's objects.
In one hand, Spring makes the job, importing all needed classes
from Model module and running tests on them.
In the other hand, Maven cries with the following error :
package com.my-app.model.my-package does not exist.
OK, Spring and Maven are 2 different tools but what should I do in the App's POM to explicitely declare that all objects from the Model module should be exported to Tests module in order to be tested ?
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.humanresources.game</groupId>
<artifactId>hrg-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Application</name>
<description>Human Resources game engine</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<modules>
<module>../hrg-model</module>
<module>../hrg-tests</module>
</modules>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
<mainClass>HrgAppApplication</mainClass>
<goal>package</goal>
</configuration>
</plugin>
</plugins>
</build>
</project>
The Tests' module POM only declares a <dependency> block on Model Module.
Neither Tests module nor Model one have any <build> block in their respective POM.
As seen here, everything should only be managed by App's POM.
So my question is : what should I add in the App's POM <build> block to effectively export all Model's packages and classes to Tests module so that it remains possible to mvn clean install the whole project ?
Thanx by advance.
Edit : POM.xml for Tests and Model modules
Tests / POM
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.humanresources.game</groupId>
<artifactId>hrg-app</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../hrg-app/pom.xml</relativePath>
</parent>
<artifactId>hrg-tests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Tests</name>
<description>Tests project</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.humanresources.game</groupId>
<artifactId>hrg-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Model / POM
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.humanresources.game</groupId>
<artifactId>hrg-app</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../hrg-app/pom.xml</relativePath>
</parent>
<artifactId>hrg-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Model</name>
<description>Tests project for Human Resources game</description>
<properties>
<java.version>1.8</java.version>
</properties>
</project>
Console Output after mvn clean install (unit test succeeds though) :
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Application [pom]
[INFO] Model [jar]
[INFO] Tests [jar]
[INFO]
[INFO] ------------------< com.humanresources.game:hrg-app >-------------------
[INFO] Building Application 1.0-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # hrg-app ---
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.3:repackage (repackage) # hrg-app ---
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # hrg-app ---
[INFO] Installing C:\Users\Fred\IdeaProjects\HumanResources\hrg-app\pom.xml to C:\Users\Fred\.m2\repository\com\humanresources\game\hrg-app\1.0-SNAPSHOT\hrg-app-1.0-SNAPSHOT.pom
[INFO]
[INFO] -----------------< com.humanresources.game:hrg-model >------------------
[INFO] Building Model 0.0.1-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # hrg-model ---
[INFO] Deleting C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) # hrg-model ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # hrg-model ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 11 source files to C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) # hrg-model ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # hrg-model ---
[INFO] Changes detected - recompiling the module!
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # hrg-model ---
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) # hrg-model ---
[INFO] Building jar: C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\target\hrg-model-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.3:repackage (repackage) # hrg-model ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # hrg-model ---
[INFO] Installing C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\target\hrg-model-0.0.1-SNAPSHOT.jar to C:\Users\Fred\.m2\repository\com\humanresources\game\hrg-model\0.0.1-SNAPSHOT\hrg-model-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\pom.xml to C:\Users\Fred\.m2\repository\com\humanresources\game\hrg-model\0.0.1-SNAPSHOT\hrg-model-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] -----------------< com.humanresources.game:hrg-tests >------------------
[INFO] Building Tests 0.0.1-SNAPSHOT [3/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # hrg-tests ---
[INFO] Deleting C:\Users\Fred\IdeaProjects\HumanResources\hrg-tests\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) # hrg-tests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # hrg-tests ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\Fred\IdeaProjects\HumanResources\hrg-tests\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) # hrg-tests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\Users\Fred\IdeaProjects\HumanResources\hrg-tests\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # hrg-tests ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\Fred\IdeaProjects\HumanResources\hrg-tests\target\test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[3,42] package com.humanresources.game.model.card does not exist
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[4,47] package com.humanresources.game.model.territory does not exist
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[5,47] package com.humanresources.game.model.territory does not exist
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Application 1.0-SNAPSHOT ........................... SUCCESS [ 1.533 s]
[INFO] Model 0.0.1-SNAPSHOT ............................... SUCCESS [ 5.104 s]
[INFO] Tests 0.0.1-SNAPSHOT ............................... FAILURE [ 3.715 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.771 s
[INFO] Finished at: 2021-02-21T18:33:11+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project hrg-tests: Compilation failure: Compilation failure:
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[3,42] package com.humanresources.game.model.card does not exist
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[4,47] package com.humanresources.game.model.territory does not exist
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[5,47] package com.humanresources.game.model.territory does not exist
See a screen capture after mvn clean install :
Problem Diagnostics
The output for the Maven execution contains the following lines for the hrg-model:
[INFO] --- spring-boot-maven-plugin:2.4.3:repackage (repackage) # hrg-model ---
[INFO] Replacing main artifact with repackaged archive
The JAR artifact of hrg-model is not a usual library after that, but an executable JAR packaged as described in the Spring Boot documentation
That executable JAR is not suitable for consumption by a Java compiler - or compiler for any other JVM-based language for that matter.
Solution
Only the Maven module which represents the final executable artifact of the project should include the invocation of the spring-boot-maven-plugin.
Please note, that your project has no such module at the moment.
I would suggest:
adding the new module with hrg-app as a parent and hrg-model as a dependency;
moving the spring-boot-maven-plugin invocation from the hrg-app module to the new module.
You may check the official guide from Spring Boot - Creating a Multi Module Project - for a step-by-step guide and explanation.
Try adding this plugin in your APPs pom.xml under plugins section of the XML's build element.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version><--your maven version--></version>
</plugin>
I'm trying to use jsonschema2pojo to convert the FHIR schema to a java object. If I use this example schema then the generated java classes are create just fine, but when I use this Json Schema then nothing is created and I don't see any errors to understand why its not created. Can anybody help me understand where the failure is?
My pom file
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>DMSAdpater</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<version>1.0.2</version>
<configuration>
<sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
<targetPackage>com.example.types</targetPackage>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.4</version>
</dependency>
</dependencies>
The Output of my mvn compile
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.example:DMSAdpater:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 13, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -----------------------< org.example:DMSAdpater >-----------------------
[INFO] Building DMSAdpater 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # DMSAdpater ---
[INFO] Deleting H:\Workspaces\HDI\Project\DMS_Adapter\target
[INFO]
[INFO] --- jsonschema2pojo-maven-plugin:1.0.2:generate (default) # DMSAdpater ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # DMSAdpater ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 11 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # DMSAdpater ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25.745 s
[INFO] Finished at: 2020-07-13T12:01:07-04:00
[INFO] ------------------------------------------------------------------------
Basically I have a Maven Project and I am trying to generate a jar of my project using mvn clean compile package through spring tool suite using below pom.xml.
After the command is executed, I get 2 jar files generated in my target folder - {project-name}.jar & {project-name}.jar.original
The .jar file contains
Spring boot framework class files having this contents while the .jar.original file contains actual class files of my application.
Snapshot of target folder
I also tried using mvn clean install but no luck with it. Moreover, the only 1 file is installed which is useless for me, because it does not contain any class files of my application but contains spring framework classes.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.commonporject</groupId>
<artifactId>commonporject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>commonporject</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2.jcc</groupId>
<artifactId>db2jcc4</artifactId>
<version>10.1</version>
</dependency>
<!-- other dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>1.8</compilerVersion>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Console:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.commonporject:commonporject >----------------------
[INFO] Building commonporject 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # commonporject ---
[INFO] Deleting C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # commonporject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # commonporject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # commonporject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # commonporject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) # commonporject ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) # commonporject ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) # commonporject ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.1.0:jar (default-jar) # commonporject ---
[INFO] Building jar: C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target\commonporject-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.0.RELEASE:repackage (repackage) # commonporject ---
[INFO] Replacing main artifact C:\Users\Aadil\Documents\workspace-spring-tool-suite-4-4.0.0.RELEASE\commonporject\target\commonporject-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.706 s
[INFO] Finished at: 2018-11-04T12:28:37+05:30
[INFO] ------------------------------------------------------------------------
spring-boot-maven plugin by default uses the repackage goal which packages all dependencies mentioned in the pom file. When this happens, your project's classes and resources jar is renamed to "original".
Please refer the below documentation for more details about this plugin.
https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html
I am working on an end-to-end project which includes backend and frontend. The frontend works fine (angular2 framework, the 'npm start' and 'ng build' works). However, when I run 'mvn clean install' from the project home folder, it gives me an error where I have no clue:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.6:jar (default-jar) on project frontend: Error assembling JAR: Failed to determine inclusion status for: .\frontend\pom.xml: The request is not supported. -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: ...
Under the project home folder, I can run 'mvn compile' successfully, but not 'mvn clean install'. It shows frontend Failure with the error message above, backend Skip.
The maven settings.xml is the original one. I have correct setting of Java Home.
Can you help me?
POM:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xlinq.gtool</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent</name>
<description>Demo project for X-LinQ Graphical Tool</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<modules>
<module>frontend</module>
<module>backend</module>
</modules>
</project>
fronted POM:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>frontend</artifactId>
<name>frontend</name>
<description>The X-LinQ frontend project</description>
<parent>
<groupId>com.xlinq.gtool</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<nodeVersion>v6.10.3</nodeVersion>
<npmVersion>3.10.10</npmVersion>
<workingDirectory>src/main/frontend</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>target/frontend</directory>
<targetPath>static</targetPath>
</resource>
</resources>
</build>
</project>
Response:
> mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent
[INFO] frontend
[INFO] backend
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building parent 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) # parent ---
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # parent ---
[INFO] Installing H:\project\pom.xml to C:\Users\x\.m2\repository\com\xlinq\gtool\parent\0.0.1-SNAPSHOT\parent-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building frontend 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) # frontend ---
[INFO] Deleting H:\project\frontend\target
[INFO]
[INFO] --- frontend-maven-plugin:1.3:install-node-and-npm (install node and npm) # frontend ---
[INFO] Node v6.10.3 is already installed.
[INFO] NPM 3.10.10 is already installed.
[INFO]
[INFO] --- frontend-maven-plugin:1.3:npm (npm install) # frontend ---
[INFO] Running 'npm install' in H:\project\frontend\src\main\frontend
[WARNING] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0 (node_modules\chokidar\node_modules\fsevents):
[WARNING] npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
[INFO]
[INFO] --- frontend-maven-plugin:1.3:npm (npm run build) # frontend ---
[INFO] Running 'npm run build' in H:\project\frontend\src\main\frontend
[INFO]
[INFO] > gtool#0.0.0 build H:\project\frontend\src\main\frontend
[INFO] > ng build
[INFO]
[INFO] Hash: 46436a79c4d4bc172d29
[INFO] Time: 52660ms
[INFO] chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 177 kB {5} [initial] [rendered]
[INFO] chunk {1} main.bundle.js, main.bundle.js.map (main) 104 kB {4} [initial] [rendered]
[INFO] chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 270 kB {5} [initial] [rendered]
[INFO] chunk {3} scripts.bundle.js, scripts.bundle.js.map (scripts) 733 kB {5} [initial] [rendered]
[INFO] chunk {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 6.01 MB [initial] [rendered]
[INFO] chunk {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
[ERROR]
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # frontend ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 36 resources to static
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # frontend ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # frontend ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory H:\project\frontend\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # frontend ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) # frontend ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) # frontend ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................. SUCCESS [ 0.350 s]
[INFO] frontend ........................................... FAILURE [03:06 min]
[INFO] backend ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:07 min
[INFO] Finished at: 2017-08-16T15:27:21+02:00
[INFO] Final Memory: 21M/357M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.6:jar (default-jar) on project frontend: Error assembling JAR: Failed to determine inclusion status for: H:\project\frontend\pom.xml: H:\project\frontend\pom.xml: The request is not supported. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :frontend
I solved this problem. Nothing wrong with the POM and Maven settings.xml. The problem is that the project was mounted in a network location. After moving it to a local hard disk drive, the mvn clean install works.
Sadly a mounted WSL drive is considered a network mount as well as that is where I'm seeing it.
Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar
and
Error assembling JAR: Failed to determine inclusion status for
were messages that I am seeing. This was not a problem with previous versions of the maven-jar-plugin (2.5)
I am trying to build an ear project with two war files inside. While building the EAR I am getting the error as "application.xml does not exist". But I have placed the application.xml in the projects META INF folder. Please find the code below. and suggest a solution to resolve this.
Below Is my 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>au.com.mercury</groupId>
<artifactId>ReplenishmentR4</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ear</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<applicationXML>src/main/application/META-INF/application.xml</applicationXML>
<generateApplicationXml>false</generateApplicationXml>
<encoding>UTF-8</encoding>
<defaultLibBundleDir>lib/</defaultLibBundleDir>
<filtering>true</filtering>
<modules>
<webModule>
<groupId>au.com.mercury</groupId>
<artifactId>Replenishment</artifactId>
<bundleFileName>Replenishment.war</bundleFileName>
</webModule>
<webModule>
<groupId>au.com.mercury</groupId>
<artifactId>ReplenishmentR3</artifactId>
<bundleFileName>ReplenishmentR3.war</bundleFileName>
</webModule>
</modules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
<finalName>ReplenishmentR4</finalName>
</build>
<dependencies>
<dependency>
<groupId>au.com.mercury</groupId>
<artifactId>Replenishment</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>au.com.mercury</groupId>
<artifactId>ReplenishmentR3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
</project>
Below is my application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application>
<module>
<web>
<web-uri>Replenishment.war</web-uri>
<context-root>/Replenishment</context-root>
</web>
</module>
<module>
<web>
<web-uri>ReplenishmentR3.war</web-uri>
<context-root>/ReplenishmentR2</context-root>
</web>
</module>
</application>
Open This Image for the project structure.
Project structure
Maven build console error:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ReplenishmentR4 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for au.com.woolworths.mercury:ReplenishmentR3:war:0.0.1-SNAPSHOT is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # ReplenishmentR4 ---
[INFO] Deleting C:\Users\xagh9\workspace\ReplenishmentR4\target
[INFO]
[INFO] --- maven-ear-plugin:2.6:generate-application-xml (default-generate-application-xml) # ReplenishmentR4 ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # ReplenishmentR4 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\xagh9\workspace\ReplenishmentR4\src\main\resources
[INFO]
[INFO] --- maven-ear-plugin:2.6:ear (default-ear) # ReplenishmentR4 ---
[INFO] Copying artifact[war:au.com.mercury:Replenishment:0.0.1-SNAPSHOT] to[Replenishment.war]
[INFO] Copying artifact[war:au.com.mercury:ReplenishmentR3:0.0.1-SNAPSHOT] to[ReplenishmentR3.war]
[INFO] Copy ear sources to C:\Users\xagh9\workspace\ReplenishmentR4\target\ReplenishmentR4
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.177 s
[INFO] Finished at: 2016-12-24T22:33:03+11:00
[INFO] Final Memory: 12M/164M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.6:ear (default-ear) on project ReplenishmentR4: Deployment descriptor: C:\Users\xagh9\workspace\ReplenishmentR4\target\ReplenishmentR4\META-INF\application.xml does not exist. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
1) The application.xml file in the EAR is not required any longer since JavaEE 5.0
2) In the maven-ear-plugin configuration, you don't generate the application.xml file :
<generateApplicationXml>false</generateApplicationXml>
and you specify the location of application.xml here : <applicationXML>src/main/application/META-INF/application.xml</applicationXML>
So, you should be sure that the application.xml file is at this location: src/main/application/META-INF
3) The most simple is not using <generateApplicationXml>false</generateApplicationXml>. It avoids you declaring the application.xml file.