Project files created with the maven-eclipse-plugin are not supported in M2Eclipse - m2e

We have a really simple Tycho project:
<properties>
<tycho-version>0.26.0</tycho-version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.build.timestamp.format>yyyyMMdd_HHmmss</maven.build.timestamp.format>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<extensions>true</extensions>
<version>${tycho-version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<!-- snipped because probably not relevant -->
</plugin>
</plugins>
</build>
When we execute the maven goal eclipse:eclipse, we get the following weird comment in the .project files of features and products:
NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.
(A nonsense exception, because we execute it on the command line, there is no M2Eclipse involved at all.)
We could probably live with that, but the .classpath files look like that:
<classpathentry kind="lib" path="C:/Users/WileCoyote/.m2/repository/p2/osgi/bundle/com.itextpdf/5.5.3/com.itextpdf-5.5.3.jar"/>
<classpathentry kind="lib" path="C:/Users/WileCoyote/.m2/repository/p2/osgi/bundle/org.acme.config/2.0.2.v201506191015/org.acme.config-2.0.2.v201506191015.jar"/>
<!-- etc. -->
And so if imported in another user's workspace, these projects don't work anymore.
Here is an explanation on how to fix the problem, but that's really a no-brainer (remove the broken class path entries from the class path, because features and products don't need them anyway).
What I really want to know is why it happens at all? What is the problem? How do I fix it?

Related

Copy Maven dependency files and runtime in jpackage

I have a JavaFX project with dependencies on SQLite and POI, so I used maven-dependency-plugin to copy all dependencies in target\lib folder. That folder contains about 21 dependencies common-codecs, curvesapi, javafx-base, javafx-fxml... etc.
To create a jpackage I'm using jpackage-maven-plugin to create an installer. I have jmods folder copied to java.home. The POM is as follows:
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>19</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>19</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.39.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<launcher>App</launcher>
<mainClass>com.example.App</mainClass>
</configuration>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<mainClass>com.example.App</mainClass>
</configuration>
</execution>
<execution>
<id>debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000</option>
</options>
</configuration>
</execution>
<execution>
<id>ide-debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</option>
</options>
</configuration>
</execution>
<execution>
<id>ide-profile</id>
<configuration>
<options>
<option>${profiler.jvmargs.arg1}</option>
<option>${profiler.jvmargs.arg2}</option>
<option>${profiler.jvmargs.arg3}</option>
<option>${profiler.jvmargs.arg4}</option>
<option>${profiler.jvmargs.arg5}</option>
</options>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<name>ExampleFX</name>
<appVersion>${project.version}</appVersion>
<icon>${basedir}/icon.ico</icon>
<vendor>Myself</vendor>
<destination>Runtime</destination>
<modulePaths>
<modulePath>C:\Program Files\Java\jmods</modulePath>
<modulePath>${project.build.directory}/classes</modulePath>
</modulePaths>
<module>com.example/com.example.App</module>
<runtimeImage>${java.home}/lib</runtimeImage>
<winDirChooser>true</winDirChooser>
<winShortcut>true</winShortcut>
<winConsole>true</winConsole>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<release>19</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
This command neither packages the lib folder in the installer, nor does it properly copies JVM, as on running the program, it gives Failed to find JVM in "C:\Program Files\Example\runtime" directory. error. Any help appreciated.
EDIT
Changed some parameters:
from<runtimeImage>${java.home}/lib</runtimeImage> to <runtimeImage>${java.home}</runtimeImage>,
added module path <modulePath>${project.build.directory}/lib</modulePath>
Now the app fails to find modules (dependencies) which are present in ${INSTALLDIR}/app/mods. Trying to add these modules require I remove runtimeImage parameter. If I do so:
<addModules>javafx.fxml,javafx.controls,
org.apache.poi.ooxml,org.apache.poi.poi,org.xerial.sqlitejdbc,SparseBitSet,
org.apache.commons.compress,org.apache.commons.codec,org.apache.commons.collections4,
org.apache.commons.io,com.github.virtuald.curvesapi,commons.math3,
org.apache.commons.collections4,org.apache.xmlbeans</addModules>
I always get error regarding any module randomly:
jlink failed with: Error: automatic module cannot be used with jlink: commons.math3 from file:///C:/Users/MY/Documents/NetBeansProjects/Example/target/lib/commons-math3-3.6.1.jar
module-info
module com.example{
requires javafx.controls;
requires javafx.fxml;
requires javafx.base;
requires javafx.graphics;
requires java.logging;
requires java.base;
requires java.sql;
requires org.apache.poi.poi;
requires org.apache.poi.ooxml;
requires org.apache.commons.codec;
requires org.apache.commons.collections4;
requires org.apache.commons.compress;
requires org.apache.commons.io;
requires commons.math3;
requires com.github.virtuald.curvesapi;
requires org.apache.logging.log4j;
requires SparseBitSet;
requires org.xerial.sqlitejdbc;
requires org.apache.xmlbeans;
opens com.example to javafx.fxml;
exports com.example;
}
Use JPackageScriptFX. Here's how to use it:
(I'll refer to JPackageScriptFX as JPS and your project as Example)
Copy your Example project folder inside JPS's folder.
Open JPS's POM, and go to <modules> section. Remove all existing module entries (jpackagefx-main,jpackagefx-module1,jpackagefx-module2). Write <module>Example</module> instead.
Change groupId to Example's groupId.artifactId.
Open Example's POM. Write <packaging>jar</packaging> beneath <version> tag.
Copy jpackagefx-main's maven-dependency-plugin from its POM and copy it to Example's POM.
Write <configuration><mainClass>com.example.App</mainClass></configuration> in javafx-maven-plugin if it isn't there already.
Copy whole of the <profiles> section from jpackagefx-main and copy it to Example's POM.
Rename ${client.version} to ${project.version} in <APP_VERSION> and <PROJECT_VERSION> (This is required especially in the case of Linux, otherwise the jpackage will fail in final stages (dpkg-deb returns with error code 2)).
Create a new class file named AppLauncher, and write following code in it:
package com.example
public class AppLauncher{
public static void main(String[] args){
App.main(args);
}
}
Depending on your platform (Windows, Linux, Mac) copy the build_app_linux.sh, build_app_mac.sh or build_app_windows.bat file inside Example's project folder. I'll refer to the linux version in the next steps, you can find appropriate lines in other platform files.
Line 13, Change MAIN_JAR="main-ui-... to MAIN_JAR="Example-... or whatever the name of your Jar file is (You can find Jar filename by building the project and simply looking its name in target folder).
Line 47, change class path to target/classes/com/Example/App.class
Line 63, append modules you want in your project (in your case, ,java.sql).
Line 92, Change to whatever name you want to give. You can also use quotes " to give space in the name.
Line 93, set --main-class to com.example.AppLauncher.
Line 97, optinally, set your own icon by modifying this line.
For Windows, additionally change line 40 to --print-module-deps target\classes\com\example\App.class > temp.txt.
Open pom.xml[parent] using Whatever IDE. I'm using netbeans, so I can clean and build the project by pressing SHIFT+F11.
If there's no error, then your installer will be present in target\installer

Maven javadoc plugin won't use my stylesheet

I'm trying to run the javadoc:javadoc goal for Maven for my Java 1.7 project. I'd like to specify my customized stylesheet in /src/main/java/stylesheet.css to use when running the goal, but the default javadoc stylesheet is used instead.
I've tried adding the following to my pom.xml file, as the https://maven.apache.org/plugins/maven-javadoc-plugin/examples/stylesheet-configuration.html documentation on the Apache Maven site suggests:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<stylesheetfile>src/main/java/stylesheet.css</stylesheetfile>
</configuration>
</plugin>
</plugins>
</reporting>
But this doesn't get the desired result when I run the maven javadoc:javadoc goal. Any suggestions?
Update: I've tried with
<configuration>
<stylesheetfile>theme-irvine.css</stylesheetfile>
</configuration>
And with
<configuration>
<stylesheetfile>${basedir}/src/main/java/theme-irvine.css</stylesheetfile>
</configuration>
in my pom.xml file, and neither of those worked, either.

Generate feature xml with feature dependencies using maven plugin

I am using the maven-feature-plugin
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>features-maven-plugin</artifactId>
<version>2.3.6</version>
<executions>
<execution>
<id>generate</id>
<phase>generate-resources</phase>
<goals>
<goal>generate-features-xml</goal>
</goals>
<configuration>
<bundles>src/main/resources/bundle.properties</bundles>
<kernelVersion>2.3.6</kernelVersion>
<outputFile>target/features.xml</outputFile>
</configuration>
</execution>
</executions>
</plugin>
This works pretty well but one of my generated features depends on the pax-cdi feature is there a way for me to get the plugin to add this for me? For example I have some dependencies defined in the bundle.properties file that cannot be resolved automatically, could I add a feature in this file as well?
You can add the feature as a maven dependency in your pom:
<dependency>
<groupId>org.ops4j.pax.cdi</groupId>
<artifactId>pax-cdi-features</artifactId>
<version>0.8.0</version>
<classifier>features</classifier>
<type>xml</type>
</dependency>
This will result a feature.xml containing the pax-cdi features (providing that karaf-maven-plugin is configured with <aggregateFeatures>true</aggregateFeatures>).
You can also leave it to the container to pull in the pax-cdi feature. Just edit $KARAF_HOME/etc/org.apache.karaf.features.cfg where you can enlist your pax-cdi-features by adding the maven url to the list of featuresRepositories.
featuresRepositories=....
....,\
mvn:org.ops4j.pax.cdi/pax-cdi-features/0.8.0/xml/features
Then add pax-cdi to the list of boot features
featuresBoot=.....,pax-cdi,...
Karaf will start the bundles of pax-cdi when it boots, so that your bundles can find those cdi packages available.
I think that the karaf convention is that the pax-cdi feature should be provided by the container itself, so you don't need to add those bundles to your feature descriptor.
To use pax-cdi feature in karaf enter the following in your Karaf shell
features:addurl mvn:org.ops4j.pax.cdi/pax-cdi-features/0.8.0/xml/features

maven-failsafe-plugin won't run on verify and does not find xml on failsafe:verify

The Maven failsafe plugin will not run on my project. If I run mvn verify only surefire runs. If I type mvn failsafe:verify it fails with the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.11:verify (default-cli) on project experiment-server: /home/user/workspace/MyProject-Main/MyProject-IntegrationTest/target/failsafe-summary.xml (The system cannot find the path specified) -> [Help 1]
So I basicly have the same problem as: failsafe plugin won't run on one project but will run on another -- why?
With the difference that my pom already looks like this:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.14.1</version>
<executions>
<execution>
<id>failsafe-integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>failsafe-verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
And this was the solution to this guys problem. Except the solutions on this site didn't work for me. Can someone point out where I messed up?
I also have the problem that I want to start a server with exec-maven-plugin in pre-integration-phase. But when I try mvn-verify it's the very last thing that gets executed.
Just found out for this one, solution is here: http://maven.apache.org/surefire/maven-failsafe-plugin/plugin-info.html
maven-failsafe-plugin, contrarely to maven-compiler-plugin for example, is NOT in the default maven build lifecycle.
Consequently, one must respect this tags hierarchy:
<project>
<build>
<pluginManagement>
<plugins>
<!-- For understanding only, below is the 'maven-compiler-plugin':
its path is 'project -> build -> pluginManagement -> plugins
-> plugin', because it's defaulty part of the maven build
lifecycle: we just 'manage' it -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
..
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- HERE is the 'maven-failsafe-plugin':
its path is 'project -> build -> plugins ->
plugin', because it's NOT defaulty part of
the maven build lifecycle: we have to
'define' it, and not just manage it as
stated earlier -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
..
</plugin>
</plugins>
</build>
<project>
Quoting from the official documentation link: "To define the plugin version in your parent POM" and "To use the plugin goals in your POM or parent POM". One must pay attention to the difference.
I moved my failsafe pom snippet to the parents pom and that seems to do the trick. I have no Idea why.

How to set custom icon for javafx native package icon on Windows

I am trying to chance the icon of the exe file while creating native bundling of javafx packaging.
I tried adding icon into pom.xml but till it wont work out for me as it gives default icon
Using Intellij IDEA IDE which contain an Pom.xml creating an package by command = mvn jfx:build-native
Here is my pom.xml:
<build>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<mainClass>com.demoApp.testapp.testApplication</mainClass>
<!-- only required if signing the jar file -->
<keyStoreAlias>example-user</keyStoreAlias>
<keyStorePassword>example-password</keyStorePassword>
<permissions>
<permission>all-permissions</permission>
</permissions>
<icon>${basedir}/src/main/resources/images/logoIcon.ico</icon>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
I have added an icon path into pom.xml ${basedir}/src/main/resources/images/logoIcon.ico
that will run while native package execute but it wont work out for me
Is any other way to do it ?
Please suggest.
i tried fx tags in pom.xml using ant,here is my changes in pom.xml
<properties>
<javafx.tools.ant.jar>${env.JAVA_HOME}\lib\ant-javafx.jar</javafx.tools.ant.jar> </properties>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>create-launcher-jar</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target xmlns:fx="javafx:com.sun.javafx.tools.ant">
<taskdef
uri="javafx:com.sun.javafx.tools.ant"
resource="com/sun/javafx/tools/ant/antlib.xml"
classpath="${javafx.tools.ant.jar}"/>
<fx:application id="fxApp"
name="${project.name}"
mainClass="com.precisionhawk.flightplanner.FlightPlannerApp"/>
<fx:jar destfile="${project.build.directory}/${project.build.finalName}-launcher">
<fx:application refid="fxApp"/>
<fx:fileset dir="${project.build.directory}/classes"/>
</fx:jar>
<attachartifact file="${project.build.directory}/${project.build.finalName}-launcher.jar"
classifier="launcher"/>
<fx:deploy>
<fx:info>
<fx:icon href="${basedir}/src/main/deploy/logoIcon.ico"></fx:icon>
</fx:info>
</fx:deploy>
</target>
</configuration>
</execution>
</executions>
</plugin>
but it wont work out..
I just struggled with the same issue using Zonsky's great javafx-maven-plugin. As of version 1.5, which you also were using, the src/main/deploy directory will be added to the classpath. The icon you want to use could be added there and it will be available on the classpath for the native builder!
I added src/main/deploy/package/windows/myapp.ico there and it finally worked :)
For you:
Create src/main/deploy/package/windows/ folder
Add icon with name ${project.build.finalName}.ico
Run mvn jfx:build-native
I haven't played with it extensively - just got it to work and wanted to share. So if you want to use icon with different name, I don't know how. Not yet at least. The <icon>...</icon> section in the config section seems to be for webstart, so I haven't been using it.
Hope you get it to work!
You need to look at the logging while building a native app. That will tell you where the installer looks for the icon files and with wich name. For the default Windows native app it looks in ./package/windows/'appname'.ico
Can't remember where 'appname' comes from, but just look at the logging while building, it will tell you. (I use the Ant targets called from my pom btw)
you can do this:
`<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<vendor>YourCompany</vendor>
<mainClass>com.alan344.MapperGenApplication</mainClass>
<appName>mybatis-friend</appName>
<bundleArguments>
<icon>${project.basedir}/src/main/resources/image/icon.ico</icon>
</bundleArguments>
</configuration>
</plugin>`

Resources