Reputation: 6450
I have my first multi-module program, project structure is:
testMods
|
├───checker
│ │
│ │
│ └───src
│ | └───main
│ | └───java
│ | | │
│ | | │
│ | | └──────sample
│ | | | └───Controller.java
│ | | | └───Main.java
| | | | └───MainLauncher.java
│ | | |
| | | └──────module-info.java
│ | |
| | └────resouces
| | └───META-INF
| |
| └────pom.xml
|
└───TextInputProgram
| │
| │
| └───src
| | └───main
| | └───java
| | │
| | │
| | └───project
| | | └───Name1.java
| | | └───Name2.java
| | | └───Name3.java
| | | └───Name4.java
| | |
| | └───module-info.java
| |
| └────pom.xml
|
└────pom.xml
POM inside checker:
<?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">
<parent>
<groupId>org.openjfx</groupId>
<artifactId>testMods</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>checker</artifactId>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>12.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>12.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>12.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>TextInputProgram</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<source>11</source>
<target>11</target>
<mainClass>sample.MainLauncher</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
POM inside TextInputProgram:
<?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">
<parent>
<groupId>org.openjfx</groupId>
<artifactId>testMods</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>TextInputProgram</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
</project>
main POM (testMods):
<?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.openjfx</groupId>
<artifactId>testMods</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<modules>
<module>checker</module>
<module>TextInputProgram</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<archive>
<source>11</source>
<target>11</target>
<manifestEntries>
<Automatic-Module-Name>selenium-api</Automatic-Module-Name>
<Automatic-Module-Name>selenium-chrome-driver</Automatic-Module-Name>
</manifestEntries>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>sample.MainLauncher</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>7.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
When I'm trying to build as jar with all dependencies using maven-assembly-plugin
, I'm getting always the issue:
Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.1.1:single (make-assembly) on project testMods: Unable to parse configuration of mojo org.apache.maven.plugins:maven-assembly-plugin:3.1.1:single for parameter source: Cannot find 'source' in class org.apache.maven.archiver.MavenArchiveConfiguration
The same issue will be even if I change the version of maven-assembly-plugin using path:
\.m2\repository\org\apache\maven\plugins\maven-assembly-plugin
Deleting org folder using \.m2\repository\org
path, didn't help to solve this issue. When maven reloaded all dependencies, I get the error: Unable to parse configuration of mojo
again.
I've noticed that instead of getting single jar for all modules, I get separately two jars, but not single for all. During compiling, I get target-folders just for separated modules, but not for main POM.
If I delete in main POM:
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
Then I don't see this error during packaging and compiling. And plugin works, but I'll get separated jars only like:
If I run one of them, I see:
no main manifest attribute, in D:\IdeaProject\testMods\testMods\checker\target\checker-1.0-SNAPSHOT.jar
But I generated in resource folder MANIFEST, as you can see my structure.
To create it, I choosed these options in Project Structure -> Artifacts:
In addition, I tried to use in main POM maven-shade-plugin
instead of maven-assembly-plugin
. In this case I can compile and package, but again I have two different jars as separated modules like:
but not main jar that includes all of this.
Can somemone tell me what I need to correct here to get finally jar that includes all modules inside?
Upvotes: 1
Views: 14975
Reputation: 598
I did a build by removing
following two lines
<source>11</source>
<target>11</target>
from maven-assembly-plugin
plugin section of parent
(testMods) pom, and the build was success
.
As per the doc of assembly:single, there is no any tag called source
or target
defined as valid parameter, thus plugin fails with cannot find 'source'
(the first invalid tag)
Upvotes: 3