Here is a minimal project:
<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.test</groupId>
<artifactId>enforcer</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-env</id>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
<configuration>
<rules>
<requireProperty>
<property>custom</property>
<message>You must set custom property.</message>
</requireProperty>
</rules>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>enforcer-dep</artifactId>
<version>1.0.0</version>
<classifier>${custom}</classifier>
</dependency>
</dependencies>
</project>
When running:
mvn -Dcustom=some-value validate
Validation goes OK.
When running:
mvn enforcer:enforce
or any phase from validate to process-resources
mvn validate
mvn initialize
mvn generate-sources
mvn process-sources
mvn generate-resources
mvn process-resources
I get expected fail with message:
[...]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-env) # enforcer ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireProperty failed with message:
You must set custom property.
[...]
But when I run any other (later) phase from compile up to deploy e.g.:
mvn install
I get the error about missing dependency but there is no fail caused by enforcer plugin:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building enforcer 1.0.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.test:enforcer-dep:jar:${custom}:1.0.0 is missing, no dependency information available
Downloading: http://repo.maven.apache.org/maven2/com/test/enforcer-dep/1.0.0/enforcer-dep-1.0.0-${custom}.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.983s
[INFO] Finished at: Fri Nov 22 09:22:24 CET 2013
[INFO] Final Memory: 7M/152M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project enforcer: Could not resolve dependencies for project com.test:enforcer:jar:1.0
.0: Could not transfer artifact com.test:enforcer-dep:jar:${custom}:1.0.0 from/to central (http://repo.maven.apache.org/
maven2): Illegal character in path at index 84: http://repo.maven.apache.org/maven2/com/test/enforcer-dep/1.0.0/enforcer
-dep-1.0.0-${custom}.jar -> [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/DependencyResolutionException
It looks for me like enforcer plugin is not executed at all, or dependencies are checked first before project can be build when running compile and later phases.
But why dependencies are not checked when running up to process-resources?
Obviously you seemed to have changed the settings of the maven installation which went wrong based on the error message:
[WARNING] Some problems were encountered while building the effective settings
[WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ...ever maven must make a connection to a remote s
erver.\n |-->\n <s... #111:5) # C:\programs\Maven\3\bin\..\conf\settings.xml
This means first clean up the conf/settings.xml file. Best is to use the default file which came via the installation. If you need to make modification do this in the users settings.xml $HOME/.m2/settings.xml or on Windows C:/Users/UserName/.m2/settings.xml
Apart from that i don't know what you like to achieve by using something like this:
[WARNING] The POM for com.test:enforcer-dep:jar:${custom}:1.0.0 is missing, no dependency information available
Downloading: http://repo.maven.apache.org/maven2/com/test/enforcer-dep/1.0.0/enforcer-dep-1.0.0-${custom}.jar
Related
I am trying to create new maven archetype to generate custom project as per my needs. My project looks like below
My archetype pom looks like 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>com.tarkshala</groupId>
<artifactId>maven-archetype-tarkshala-service-models</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>tarkshala-service-models-archetype</name>
<!-- Used to point local artifacts to the hosted repo , Starts -->
<distributionManagement>
<repository>
<id>nexus</id>
<name>maven-releases</name>
<url>http://maven.tarkshala.com:10081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<name>maven-snapshots</name>
<url>http://maven.tarkshala.com:10081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<!-- Ends -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>18</source>
<target>18</target>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
<!-- Check we can delete compiler properties-->
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
</project>
and my archetype.xml looks like following
<archetype-descriptor xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
name="maven-archetype-sample" partial="false">
<requiredProperties>
<!-- This is used in pom.xml of the future app. -->
<requiredProperty key="projectName">
<defaultValue>TarkshalaService</defaultValue>
</requiredProperty>
</requiredProperties>
<fileSets>
<fileSet filtered="true" packaged="true">
<directory>src/main/java</directory>
<includes>
<include>**/**.java</include>
</includes>
</fileSet>
<fileSet filtered="true">
<directory/>
<includes>
<include>*.yml</include>
<include>.gitignore</include>
<include>*.md</include>
<include>*.xml</include>
</includes>
</fileSet>
</fileSets>
</archetype-descriptor>
mvn clean install is successful when done on archetype, but mvn generate fails as following
~/W/r/maven-archetype-tarkshala-service-models (master|✚1) [1]$ mvn archetype:generate \
-DarchetypeGroupId=com.tarkshala \
-DarchetypeArtifactId=maven-archetype-tarkshala-service-models \
-DarchetypeVersion=1.0-SNAPSHOT \
-DgroupId=com.tarkshala \
-DartifactId=dhaba-models \
-DprojectName=DhabaModels
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.tarkshala:maven-archetype-tarkshala-service-models:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 31, 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] -------< com.tarkshala:maven-archetype-tarkshala-service-models >-------
[INFO] Building tarkshala-service-models-archetype 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.2.1:generate (default-cli) > generate-sources # maven-archetype-tarkshala-service-models >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.2.1:generate (default-cli) < generate-sources # maven-archetype-tarkshala-service-models <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.2.1:generate (default-cli) # maven-archetype-tarkshala-service-models ---
[INFO] Generating project in Interactive mode
[WARNING] Archetype not found in any catalog. Falling back to central repository.
[WARNING] Add a repository with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.892 s
[INFO] Finished at: 2023-01-28T07:38:18+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate (default-cli) on project maven-archetype-tarkshala-service-models: Cannot invoke "org.codehaus.plexus.util.xml.Xpp3Dom.getValue()" because the return value of "org.codehaus.plexus.util.xml.Xpp3Dom.getChild(String)" is null -> [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/MojoFailureException
Can someone please help to point what exactly am I doing wrong.
I would like to generate a runnable JAR for my Eclipse Java projects. The JAR should contain all my code, with unmodified namespaces, classes, resources etc.
My workspace is organized into a multitude of different projects.
When I right-click a project node in Project Explorer, and select "Run As > Maven install", I get the following:
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< foo.Project1:foo.Project1 >----------------------
[INFO] Building foo.Project1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for foo.Project2:foo.Project2:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.220 s
[INFO] Finished at: 2020-06-26T12:20:11+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project foo.Project1: Could not resolve dependencies for project foo.Project1:foo.Project1:jar:0.0.1-SNAPSHOT: Could not find artifact foo.Project2:foo.Project2:jar:0.0.1-SNAPSHOT -> [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/DependencyResolutionException
foo.Project1 runs fine under Eclipse. Its pom.xml file is:
<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>
<groupId>foo.Project1</groupId>
<artifactId>foo.Project1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>foo.Project2</groupId>
<artifactId>foo.Project2</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
(A ZIP of the two projects can be accessed here: https://wetransfer.com/downloads/b9bb4aa840daa6e7b2dd2c793acdb56420200626103047/32c0fd)
I tried the first solution suggested in How can I create an executable JAR with dependencies using Maven? (with 2300+ score) by:
1: adding the following in the build section of the pom.xml:
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>foo.Project1.Application</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
2: right-clicking the project node, then "Run As > Maven build..."
3: defining "Goals" as: clean compile assembly:single, and hitting Run
Same errors.
What am I doing wrong?
If you want to use foo.Project2 as dependency, you need to build it first with clean install.
You always need to build a project before you can use it as dependency in the Maven build.
Eclipse cheats a bit by also allowing you to reference projects from the workspace and therefore allows you to run the program. But for the "real build", you need to build everything in the right order.
I have a JavaFX app that I have successfully built and run with Java SDK 1.8. I am trying to move it to Java 11 with an ultimate goal of using Java 14 and can not create a runnable jar. To try and understand the process I have downloaded the javafx helloFX example and tried to follow the instructions at https://openjfx.io/openjfx-docs/#modular for Maven. When I run the mvn clean javafx:jlink I get the error:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< org.openjfx:hellofx >-------------------------
[INFO] Building demo 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # hellofx ---
[INFO] Deleting C:\Users\jungl\eclipse-workspace\helloFX\Maven\hellofx\target
[INFO]
[INFO] --- javafx-maven-plugin:0.0.3:jlink (default-cli) # hellofx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\jungl\eclipse-workspace\helloFX\Maven\hellofx\src\main\resources
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\jungl\eclipse-workspace\helloFX\Maven\hellofx\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.345 s
[INFO] Finished at: 2020-04-14T14:52:18+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.3:jlink (default-cli) on project hellofx: Error: jlink requires a module descriptor -> [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
The pom.xml is
<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>org.openjfx</groupId>
<artifactId>hellofx</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>demo</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>HelloFX</mainClass>
<jlinkImageName>hello></jlinkImageName>
<jlinkZipName>hellozip></jlinkZipName>
</configuration>
</plugin>
</plugins>
</build>
</project>
<!-- https://mvnrepository.com/artifact/com.zenjava/javafx-maven-plugin -->
Can anyone point me in the correct direction as I am failing to understand the issue.
The provided example is not structured as the tutorial says. The maven version has been updated under the CommandLine folder. If you go to: ..\CommandLine\Modular\Maven\helloFX and enter the commands mvn clean javafx:run, clean javafx:jlink, target\hellofx\bin\launcher it runs as described in the tutorial.
To simplify what I'm asking: what is a test failure and how do I rectify it?
I'm new to Maven, and I'm trying to get the graphical plotting application Jzy3d to work on my computer. I've updated all of the plugins to be the newest versions in the POM files for the parent and child modules, as well as checking that Maven is pointing to the newest JRE I have installed (which it is).
My dependency trees are also all fine, which covers many of the avenues for which I have seen this error on this forum and elsewhere.
I simply cannot isolate the issue.
The error message when running mvn package -e is as follows:
D:\Program Files\jzy3d-api-master>mvn package -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Jzy3d Master Project
[INFO] JDT core (fork of https://github.com/yonatang/JDT)
[INFO] Jzy3d API
[INFO] Jzy3d SWT Tools
[INFO] Jzy3d Tutorials
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building Jzy3d Master Project 0.9.2-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building JDT core (fork of https://github.com/yonatang/JDT)
0.9.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # jzy3d-jdt-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # jzy3d-jdt-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # jzy3d-jdt-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 18 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) # jzy3d-jdt-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) # jzy3d-jdt-core ---
[INFO] Surefire report directory: D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running il.ac.idc.jdt.SmokeTest Configuring TestNG with: TestNG60Configurator Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.639 sec <<< FAILURE! - in il.ac.idc.jdt.SmokeTest shouldRunOnExampleData(il.ac.idc.jdt.SmokeTest) Time elapsed: 0.412 sec <<< FAILURE! java.lang.AssertionError: t1_1000.tsin trangulation is correct for smf
at il.ac.idc.jdt.SmokeTest.shouldRunOnExampleData(SmokeTest.java:28)
Results :
Failed tests: SmokeTest.shouldRunOnExampleData:28 t1_1000.tsin trangulation is correct for smf
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Jzy3d Master Project ............................... SUCCESS [ 0.022 s]
[INFO] JDT core (fork of https://github.com/yonatang/JDT) . FAILURE [ 8.853 s]
[INFO] Jzy3d API .......................................... SKIPPED
[INFO] Jzy3d SWT Tools .................................... SKIPPED
[INFO] Jzy3d Tutorials .................................... SKIPPED
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 9.772 s
[INFO] Finished at: 2016-01-13T11:56:26+00:00
[INFO] Final Memory: 8M/22M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project jzy3d-jdt-core: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project jzy3d-jdt-core: There are test failures.
Please refer to D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\target\surefire-reports for the individual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.
Please refer to D:\Program Files\jzy3d-api-master\jzy3d-jdt-core\target\surefire-reports for the individual test results.
at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:91)
at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:320)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:892)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:755)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more [ERROR] [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/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <goals> -rf :jzy3d-jdt-core
My parent POM file is:
<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>org.jzy3d</groupId>
<artifactId>jzy3d-master</artifactId>
<version>0.9.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Jzy3d Master Project</name>
<url>http://www.jzy3d.org</url>
<description>A java API to draw 3d charts.</description>
<developers>
<developer>
<id>martin.pernollet</id>
<name>Martin Pernollet</name>
<email>martin#jzy3d.org</email>
<url>http://twitter.com/jzy3d</url>
</developer>
<developer>
<id>nils.hoffmann</id>
<name>Nils Hoffmann</name>
</developer>
<developer>
<id>juan.barandiaran</id>
<name>Juan Barandiaran</name>
</developer>
</developers>
<licenses>
<license>
<name>The (New) BSD License</name>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/jzy3d/jzy3d-api</connection>
</scm>
<issueManagement>
<system>Github</system>
<url>https://github.com/jzy3d/jzy3d-api/issues</url>
</issueManagement>
<modules>
<module>jzy3d-api</module>
<!-- <module>jzy3d-javafx</module> -->
<module>jzy3d-swt</module>
<module>jzy3d-jdt-core</module>
<module>jzy3d-tutorials</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.jzy3d>0.9.2-SNAPSHOT</version.jzy3d>
<version.java.source>1.6</version.java.source>
<version.java.target>1.6</version.java.target>
<version.mvn.compiler>3.0</version.mvn.compiler>
<version.mvn.ftp>1.0-beta-6</version.mvn.ftp>
<version.mvn.deploy>2.4</version.mvn.deploy>
<version.mvn.javadoc>2.9.1</version.mvn.javadoc>
<version.libs.junit>4.10</version.libs.junit>
<version.libs.swt>4.2.1</version.libs.swt>
</properties>
<distributionManagement>
<repository>
<id>jzy3d-ftp</id>
<name>Jzy3d Maven Folder</name>
<url>ftp://ftp.cluster013.ovh.net/maven/releases</url>
</repository>
<snapshotRepository>
<id>jzy3d-ftp</id>
<name>Jzy3d Maven Folder SNAPSHOTS</name>
<url>ftp://ftp.cluster013.ovh.net/maven/snapshots</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>jzy3d-snapshots</id>
<name>Jzy3d Snapshots</name>
<url>http://maven.jzy3d.org/snapshots</url>
</repository>
<repository>
<id>jzy3d-releases</id>
<name>Jzy3d Snapshots</name>
<url>http://maven.jzy3d.org/releases</url>
</repository>
</repositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<stylesheetfile>jzy3d-api/doc/layout.css</stylesheetfile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>[ groupId ]</groupId>
<artifactId>[ artifactId ]</artifactId>
<version>[ version ]</version>
<type>[ packaging ]</type>
<classifier> [classifier - optional] </classifier>
<overWrite>[ true or false ]</overWrite>
<outputDirectory>[ output directory ]</outputDirectory>
<destFileName>[ filename ]</destFileName>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>${version.mvn.ftp}</version>
</extension>
</extensions>
</build>
</project>
And the child POM for which the error message keeps running (jzy3d-jdt-core) is:
<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>
<parent>
<groupId>org.jzy3d</groupId>
<artifactId>jzy3d-master</artifactId>
<version>0.9.2-SNAPSHOT</version>
</parent>
<artifactId>jzy3d-jdt-core</artifactId>
<name>JDT core (fork of https://github.com/yonatang/JDT)</name>
<description>Java Delaunay Triangulation Core Library</description>
<properties>
<testng.version>6.5.2</testng.version>
<hamcrest.version>1.3.RC2</hamcrest.version>
</properties>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
To simplify what I'm asking: what is a test failure and how do I rectify it?
During the build of a Maven project, it executes automatically what are called unit tests. Those are Java classes whose purpose are to verify the behaviour of specific methods of the project. In this case, it turns out that one of the test is failing in your build.
Update 12 March 2016: the issue mentioned in this post was fixed!
There is indeed a problem with the tests of the jzy3d library when run on Windows. I checked out the master of their GitHub and I had the same error as you.
The reason is that, during the unit tests, the library is checking if the contents of two files are equal. However, one file is created with the line separator of the current OS, while the control file has Unix line separator.
If you take a look at the file jzy3d-jdt-core\src\test\resources\outputs\t1_1000.tsin_result.tsin, you will notice that it uses the Unix \n line separator. The shouldRunOnExampleData test that is failing is creating a temporary file to verify against that control file. On my Windows machine, this temporary file was created in C:\Users\{UserName}\AppData\Local\Temp\jdt-4971059362436436156.smf and, if opened, you can see that it uses Windows line separator \r\n. Hence, the two files are not equal and the test fails.
A possible solution, targeted at the developers of that library, is to use IOUtils.contentEqualsIgnoreEOL inside the test shouldRunOnExampleData, since this method does not check for the line endings when comparing two input streams. I created the issue 52 for this problem and submitted a pull request, that is now merged and closed.
A solution for you, user of the library, is either:
to change the line endings of each file inside jzy3d-jdt-core\src\test\resources\outputs with Windows line separator. If you are using Notepad++ to open the file, you can simply change the line-endings by going to "Edit > EOL Conversion > Windows format" and save the file.
to fix the code by using contentEqualsIgnoreEOL inside the class SmokeTest (the arguments then need to be wrapped with an InputStreamReader).
to skip the tests with mvn clean install -DskipTests=true.
In my case, I changed the code of the test to ignore the line endings. The rest of the build went fine.
A test failure is a negative outcome on an assertion made when a test is implemented. You basically get an unexpected result back from a called method or a field you are reading.
-> it is broken and it has to be fixed. That does not mean you have to fix is.
mvn package -Dmaven.test.skip=true
might help building the sources.
But instead of building the sources yourself, you could just download the binaries. These seem to be available on the web page as well.
When I run mvn package -e on fresh clones of either the master or the 0.9.1 branch of jzy3d, all tests pass and the maven build is successful.
From your output above, it's the shouldRunOnExampleData test in src/test/java/il/ac/idc/jdt/SmokeTest.java (in the jzy3d-jdt-core submodule) that is failing for you. Looking at the source code of that test, it's pretty clear that it was designed to run on some flavor of Unix, since it references hard coded paths "/inputs/" and "/outputs/".
Also from your output above, it's clear that you are running on some flavor Windows, so it's not terribly surprising that the test does not pass for you. If you want to make the test pass, you might change those to "\\inputs\\" and "\\outputs\\", respectively, or use the more flexible File.separator that should work for every OS.
If you don't care about the tests passing, and just want to build the jar files produced by mvn package -e, then you can instead run mvn package -e -DskipTests. (Setting -Dmaven.test.skip=true should also have worked; see the Maven documentation on skipping tests.)
I'm trying to run exec-maven-plugin's exec:java goal on a simple two-module project where one module depends on the other. So far I can't find a configuration that works. Here's a boiled-down test case:
+ exec-multi-module-test/
+ pom.xml
+ module1/
+ pom.xml
+ src/
+ main/
+ java/
+ HelloPrinter.java
+ module2/
+ pom.xml
+ src/
+ main/
+ java/
+ MyMain.java
Here's the parent 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.mkscrg.sandbox</groupId>
<artifactId>exec-multi-module-test</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>module1</module>
<module>module2</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
</plugin>
</plugins>
</build>
</project>
module1's 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>
<parent>
<artifactId>exec-multi-module-test</artifactId>
<groupId>com.mkscrg.sandbox</groupId>
<version>1.0</version>
</parent>
<artifactId>module1</artifactId>
</project>
module2's pom:
4.0.0
<parent>
<artifactId>exec-multi-module-test</artifactId>
<groupId>com.mkscrg.sandbox</groupId>
<version>1.0</version>
</parent>
<artifactId>module2</artifactId>
<dependencies>
<dependency>
<groupId>com.mkscrg.sandbox</groupId>
<artifactId>module1</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
This project compiles successfully from the top, but running mvn exec:java -Dexec.mainClass=myMain fails:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] exec-multi-module-test
[INFO] module1
[INFO] module2
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building exec-multi-module-test 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) # exec-multi-module-test >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) # exec-multi-module-test <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # exec-multi-module-test ---
[WARNING]
java.lang.ClassNotFoundException: MyMain
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:680)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] exec-multi-module-test ............................ FAILURE [0.363s]
[INFO] module1 ........................................... SKIPPED
[INFO] module2 ........................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.566s
[INFO] Finished at: Mon Jun 18 14:11:54 PDT 2012
[INFO] Final Memory: 3M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project exec-multi-module-test: An exception occured while executing the Java class. MyMain -> [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
What's the right way to configure this project to allow exec:java to see MyMain?
EDIT: Here's a gist if you'd like to try this yourself: https://gist.github.com/2950830
EDIT: Clarification: I know it's possible to mvn install and then either run exec:java from module2's directory or use the -pl flag from the top. However, I'd like to avoid running mvn install. It shouldn't be necessary to modify my local repository in order to run this goal in a multi-module project. Just as mvn compile "just works" with a multi-module project, so should other goals/phases.
Goals in a multi-module project, when run from the parent, will run against all modules. I don't think that's what you want. You can try:
mvn exec:java -pl module2 -Dexec.mainClass=MyMain
That might work? More info:
Running a specific Maven plugin goal from the command line in a sub-module of a multi-module reactor project
However, I think it's more intuitive to change directory to the sub-module containing the executable before running it.
You should bind the exec-maven-plugin to a maven lifecycle goal, say verify.
Since you want the plugin to be executed only for module2, define the plugin configurations in the parent pom within pluginManagement. Use the same only in module 2.
Then run the following:
mvn verify -Dexec.mainClass=MyMain.
parent pom
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
module 2
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
See this answer for a single-command alternative without mvn install:
https://stackoverflow.com/a/26448447/1235281
By using skip in the parent pom.xml, you can tell Maven to only run exec:java on a specific submodule.
GitHub:
https://github.com/Oduig/mavenfiddle