I have a simple Jenkins build that pulls down my project from github, builds it and reports the status of the build.
I want to have configure Jenkins to publish the resulting JAR file to a TARGET-SNAPSHOTS branch in my project.
Currently my project .gitignore's /target/*
I was looking at GitPublisher but this appears to push the entire build out, rather than just the jar file.
Thoughts on the best way to do this/if this is possible?
Thanks
I think you have many possibility. One of them is to run post-build script. It can be written is shell.
See Post build task
Simple script:
find . -name "*.jar" -exec scp {} user#myhost.com:/path/for/build/${BUILD_TAG} \;
Other:
Publish Over ... (ssh, ftp, cifs)
Since you're using maven and you said the github downloads section is acceptable, you can use the github downloads plugin - https://github.com/github/maven-plugins. I use this for deploying the Riak java client to our downloads section as part of the build.
In your ~/.m2/settings.xml you need:
<settings>
<profiles>
<profile>
<id>github</id>
<properties>
<github.global.userName>YourGithubUser</github.global.userName>
<github.global.password>YourGithubPass</github.global.password>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
</settings>
Then in your project's .pom something like:
<profile>
<id>githubUpload</id>
<activation>
<property>
<name>github.downloads</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>downloads-maven-plugin</artifactId>
<version>0.4</version>
<configuration>
<description>${project.version} release of ${project.name}</description>
<override>false</override>
<includeAttached>true</includeAttached>
</configuration>
<executions>
<execution>
<goals>
<goal>upload</goal>
</goals>
<phase>install</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
(I'm doing it as part of the install phase - you can do however you'd like)
Then simply add -Dgithub.downloads=true to your maven build -
mvn install -Dgithub.downloads=true
The web page for the plugin lists all the options for including/excluding files, etc.
Related
I'm creating new JavaFX application. I have done it, now i need to build exe file. After build I have installed it, then i launch the program and nothing. There is no application window, it was showing only in task manager...
Project have no errors, just some warrnings. I'am using http connections in it, maybe i need to declare permissions or something? Where can i do it if it's a problem?
I've tried to generate new build.xml, include newest sdk/jre, installed new version of java in my computer.
Java cannot build an exe file by itself. Every client who needs to run the application needs an appropriate JRE installed to run the application. Therefore you would need some software that packages the jar and the JRE into an exe file to install it or packages the jar and JRE into one single exe file which executes your program.
It has nothing to do with your http connections or build.xml.
However your app will run when you call it via the command line java -jar YOUR_APP.jar
If you just want to run your program by double clicking the jar file (and not build an exe), you can take a look at the following paragraphs.
For Maven
If you are building your project with Maven you can try the following POM settings to have your program be executable from the jar file (double click the jar file to start the JavaFX application):
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.1.4</version>
<configuration>
<mainClass>PATH TO YOUR MAIN CLASS (e.g. com.foo.Main)</mainClass>
<allPermissions>true</allPermissions>
</configuration>
<executions>
<execution>
<id>create-jfxjar</id>
<phase>package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>PATH TO YOUR MAIN CLASS (e.g. com.foo.Main)</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>
</plugins>
</build>
[...]
I recommend you exporting it as an jar file because it can be excecuted on linux, too and it fixes your problem because it can contain all the data you need just like fxmls!
Just export your project as an runnable jar and this window will appear!
Click here! I don't have enough reputation (but it works ;) )
And now you are finished!
In NetBeans -> Project properties -> Actions -> Run project - I can setup runfx.args property with command-line arguments and in runtime, application can see them. I didn't find a way to do the same for tests (Test file, Test project actions). Any help?
Solved with maven and surefire plugin. Arguments are passed to tests as system properties. Surefire configuration looks like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>argName</name>
<value>argValue</value>
</property>
</systemProperties>
</configuration>
</plugin>
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.
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>`
I am currently working on a project that includes using JNotify to monitor when a directory/file has been created, renamed/modified, and deleted. The project is being built in Java 6, not Java 7. JNotify uses JNI to hook into the native OS to monitor the directory/file. My problem is that I need to get JNotify into our repo but I want it to be built so that the java.library.path (DLL) is packaged with the JNI JAR. How would I go about doing that in Maven?
I was able to find the solution I needed using the following maven plugin: http://code.google.com/p/mavennatives/
You must probably upload the jar manually to your archiva instance.
The repository format is fixed, so you will need to perform the rename after retrieving the artifact. That depends how you intend to use it after it is retrieved.
This is a common pattern is something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<stripVersion>true</stripVersion>
</configuration>
<executions>
<execution>
<id>copy-jnotify</id>
<configuration>
<includeArtifactIds>JNotify</includeArtifactIds>
<outputDirectory>${project.build.directory}/my-app</outputDirectory>
</configuration>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
You can use this with the appropriate list of artifacts that will all be copied into the target/my-app directory