I'm using javafx-maven plugin to create a javafx webstart application. I had some issues signing the jar files with the javafx-maven plugin. what I want to do is, package(jar) the application with javafx-maven plugin and then sign the jar files using maven-jarsigner-plugin .
How do i execute the maven-jarsigner-plugin to sign my files after the application is packaged?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<archiveDirectory>target/jfx/app/</archiveDirectory>
<includes>
<include>**/*.jar</include>
</includes>
<keystore>path tp keystore</keystore>
<alias>alias</alias>
<storepass>password</storepass>
<keypass>password</keypass>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.3.0</version>
<configuration>
<bundler>jnlp</bundler>
<mainClass>com.myorg.myapp.launcher.myappLauncher</mainClass>
<bundleArguments>
<jnlp.allPermisions>true</jnlp.allPermisions>
<jnlp.includeDT>true</jnlp.includeDT>
<jnlp.outfile>myapp</jnlp.outfile>
</bundleArguments>
</configuration>
</plugin>
To workaround this I moved signing to verify phase.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>signing</id>
<goals>
<goal>sign</goal>
<goal>verify</goal>
</goals>
<phase>verify</phase>
<inherited>true</inherited>
<configuration>
...
</configuration>
</execution>
</executions>
</plugin>
Then I invoke maven like this:
mvn verify
Or make verify your default goal
Alternatively you can move javafx-maven plugin to the "prepare-package" phase:
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.1.0</version>
<configuration>
<bundler>jnlp</bundler>
<mainClass>com.myorg.myapp.launcher.myappLauncher</mainClass>
<bundleArguments>
<jnlp.allPermisions>true</jnlp.allPermisions>
<jnlp.includeDT>true</jnlp.includeDT>
<jnlp.outfile>myapp</jnlp.outfile>
</bundleArguments>
</configuration>
<executions>
<execution>
<id>create-jfxjar</id>
<phase>prepare-package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
</executions>
</plugin>
Related
I have to exclude from Versions Maven Plugin command (use-latest-versions), a dependency that I don't want to automatically update.
Here is the doc:
https://www.mojohaus.org/versions-maven-plugin/use-latest-releases-mojo.html#excludes
This is how I have implemented the excludes optional parameter in the pom.xml file:
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>use-latest-versions</goal>
</goals>
<configuration>
<excludes>["org.mongodb:mongodb-driver-sync:jar:4.2.3"]</excludes>
</configuration>
</execution>
</executions>
</plugin>
...
Anyway during maven validate, the mongodb dependency is updated, ignoring the excludes parameters. Where is the mistake?
EDIT:
Now it works. Below the correct configuration:
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>use-latest-versions</goal>
</goals>
<configuration>
<excludes>
<exclude>org.mongodb:mongodb-driver-sync:jar:4.2.3</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
...
I have a hybrid application : Spring Boot and ReactJS.
While running/building/generating WAR, I have set the pom.xml to copy the npm run build generated files from dist folder to template(spring) folder.
But while running mvn clean install, file are copied before the npm run build command and then the npm run build and WAR is generated. That'swhy the frontend files are stale.
My pom.xml example is :
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>prepare-package</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/public</outputDirectory>
<outputDirectory>${basedir}/src/main/resources/templates</outputDirectory>
<resources>
<resource>
<directory>${basedir}/dist</directory>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>prepare-package2</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/main/resources/static</outputDirectory>
<resources>
<resource>
<directory>${basedir}/dist/static</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v11.10.0</nodeVersion>
<npmVersion>6.7.0</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<!-- <execution>
<id>test</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>test</phase>
<configuration>
<arguments>test</arguments>
<environmentVariables>
<CI>true</CI>
</environmentVariables>
</configuration>
</execution> -->
</executions>
</plugin>
</plugins>
</build>
How do I configure so that the files are copied after npm run build ?
For similar task it makes sence to use gradle instead of maven. Tasks are much more flexible.
For example:
task buildFE(type: Exec) {
workingDir '../../FrontEnd'
commandLine 'buildFE.bat'
}
task CopyJava {
copy{
from '../OpenJDK'
into '../../Release/OpenJDK'
}
}
How can I make it build regular artifact not containing "one-jar" in the name?
I am using following settings in my POM:
<plugin>
<groupId>com.jolira</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
<executions>
<execution>
<configuration>
<mainClass>package.ClassName</mainClass>
<onejarVersion>0.97</onejarVersion>
<attachToBuild>true</attachToBuild>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<configuration>
<filename>${project.artifactId}-${project.version}.${project.packaging}</filename>
</configuration>
or, any other pattern you would like.
just add
<configuration>
<classifier>WhatEverStringYouWant</classifier>
</configuration>
I use maven in my java build process. The following is a snippet of code that creates an single jar with all dependencies. In order to reduce the data transfer on small changes to the build I'd like to place all project files (including dependencies) in the folder target/build . I plan to rsync the folder with the remote machine running the app and run the app with:
java -cp target/build/* <classname>
How do I modify this snippet to achieve this? I've read the documentation here but don't know how to piece the fix together:
http://maven.apache.org/plugins/maven-assembly-plugin/
http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html
http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<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>
Are you asking how to get maven to copy your dependencies to the target folder when you build?
I think you want the maven dependency plugin. It copies the dependencies of your project to an output folder you specify.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${targetDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
It sounds like you may also need to maven jar plugin to tell it where to package your jar to.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>${dir}</outputDirectory>
</configuration>
</plugin>
Use the maven dependency plugin
It has the gole: copy-dependencies. This should do what you want.
Example (take from the documentation)
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
I am interested in writing an annotation processor for the maven-processor-plugin. I am relatively new to Maven.
Where in the project path should the processor Java source code go (e.g.: src/main/java/...) so that it gets compiled appropriately, but does not end up as part of my artifact JAR file?
The easiest way is to keep your annotation processor in a separate project that you include as dependency.
If that doesn't work for you, use this config
Compiler Plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
<inherited>true</inherited>
<executions>
<execution>
<id>default-compile</id>
<inherited>true</inherited>
<configuration>
<!-- limit first compilation run to processor -->
<includes>path/to/processor</includes>
</configuration>
</execution>
<execution>
<id>after-processing</id>
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
</goals>
<inherited>false</inherited>
<configuration>
<excludes>path/to/processor</excludes>
</configuration>
</execution>
</executions>
</plugin>
Processor Plugin:
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>compile</phase>
<configuration>
<processors>
<processor>com.yourcompany.YourProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>
(Note that this must be executed between the two compile runs, so it is essential that you place this code in the pom.xml after the above maven-compiler-plugin configuration)
Jar Plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<excludes>path/to/processor</excludes>
</configuration>
<inherited>true</inherited>
</plugin>