There are two different javafx applications using javafx-maven-plugin to generate native windows installer. In both applications the installers are generated and can be seen at target\jfx\native .
When the first app installer setup installation process is started, setup shows files are copied in C:\Users\Yunus\AppData\Local\CooperativeERP.
The problem is when the second application installation process is started it goes to the same folder and updates some files which makes first app installed unusable.
Plugin Maven XML is as follows:
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.6.0</version>
<configuration>
<mainClass>re.iprocu.coperativeerp.MainApp</mainClass>
<bundleArguments>
<licenseFile>termsOfService.rtf</licenseFile>
</bundleArguments>
<additionalAppResources>src/main/additionalAppResources</additionalAppResources><!-- name does not matter, it's just some folder :D -->
<!-- DO SHOW DEBUG-OUTPUT -->
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<!-- required before build-native -->
<id>create-jfxjar</id>
<phase>package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
<execution>
<id>create-native</id>
<phase>package</phase>
<goals>
<goal>build-native</goal>
</goals>
</execution>
</executions>
</plugin>
What should i do to make the two setup install as different application and not to get to each others way.
Found out that zen java maven plugin uses a Main class package as unique identifier for application, and in this particular case both application had the same package name.
Changing package for one application solved my problem.
Related
I have created a application. In this application I have doubt that when getting output I need to include lib (library folder which includes all supporting jar files) but I need in a single jar files which must be include all supporting jars. Is it possible? I am using Netbeans.
You don't tell us what you are using to build your code. I'm going to guess at maven (because I know the answer is in Maven!). What you need is:
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- Add your other plug-ins here -->
</plugins>
</build>
I have a web application with spring and maven. The application is divided into maven modules. I have an "application-web" module that generates war. Another "application-ear" module that generates an ear. And another "application-static" with css, js and images that generates a zip file.
This would be the outline of my application:
application
application-web (java code)
application-ear
application-static (css, js and images)
application-resources (language properties)
I want to deploy the eclipse use files of "static" module, instead of using the files in the "application/src/main/webapp" directory. How can I do this? It is possible?
Don't waste your time with unpacking resources, everything works out of the box:
Resource bundles: the are always loaded from the classpath, regardlessly it is exploded (WEB-INF/classes) or compressed (WEB-INF/lib)
Serving static resources: bundle them up in a JAR and use either Tomcat (Servlet 3.0) feature to serve from META-INF/resources, see here or use Spring's built in mvc:resources element.
Simply add the dependency snippets in your WAR POM and your are done.
You can use the maven dependency plugin to unpack your static resources included in the zip file using the following:
In your application-web.pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-resources</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<outputDirectory>resources</outputDirectory>
<includeArtifactIds>application-static</includeArtifactIds>
<includeGroupIds>your group id</includeGroupIds>
<includes>**/*.js,**/*.css</includes>
</configuration>
</execution>
</executions>
</plugin
This work:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeTypes>pom</excludeTypes>
<includeArtifactIds>application-static</includeArtifactIds>
<includeGroupIds>com.foo.foo.application</includeGroupIds>
<outputDirectory>src/main/webapp</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<finalName>${project.artifactId}-${project.version}</finalName>
</build>
But I have another problem, with this solution only copy the static files when I execute clean package. If I run the application-web with eclipse and I do changes in a js file in application-static, the changes have no effect until I execute clean package. Any solution for this?
I am trying to automate testing for my Android app using Maven and Robolectric. The problem that I have is that I won't be running the tests on my local machine and the Android SDK won't be installed on the machine running the tests. I have used the maven-dependency-plugin to grab the sdk from our repository and unpacked it in the process resources phase, the problem is that this occurs after the need to access the files. When I try to use the apk packaging it never gets to the SDK download because it can't find the SDK. So my question is this: Is it possible to trigger this download before anything else happens in the build? If anybody has any light to shed on how to properly install the sdk at build time it would be much appreciated. Let me know if I can add any additional information.
Both Robolectric and maven-android-plugin both need SDK. Android plug-in requires build tools/adb while Robolectric needs the corresponding android.jar.
So, you'll have to create maven tasks/goals for:
Download SDK zip from some url.
Unpack the zip on test machine, in a directory.
update the android.sdk.path property of POM, to point to sdk directory.
Some snippets I found, might help:
Download:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>download-android-sdk</id>
<phase>pre-integration-test</phase>
<goals>
<goal>download-single</goal>
</goals>
<configuration>
<url>http://dowloadsite.com/<url>
<fromFile>/downloads/sdk.zip</fromFile>
<toDir>${project.build.directory}/sdk</toDir>
</configuration>
</execution>
</executions>
</plugin>
Unpack:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>unpack-sdk</id>
<phase>pre-integration-test</phase>
<configuration>
<tasks>
<unzip src="${project.build.directory}/sdk/sdk.zip" dest="${project.build.directory}/sdk/" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Explanation:
I currently have a Java Web Project in Netbeans and I'm using Maven. Recently I changed the pom in the project in order to generate 2 war files when building: one for development (which I want Netbeans to deploy when selecting "Run Project") and another one for production.
To maintain a certain standard with a previous deployment, I kept the production WAR with the same (default) name of ReportsPortal.war and the development version with a -dev appended.
Reference:
This is the section of my pom file that I changed:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>package-prod</id>
<phase>package</phase>
<configuration>
<webResources>
<resource>
<directory>src/main/env/prod</directory>
</resource>
</webResources>
</configuration>
<goals>
<goal>war</goal>
</goals>
</execution>
<execution>
<id>package-dev</id>
<phase>package</phase>
<configuration>
<classifier>dev</classifier>
<webResources>
<resource>
<directory>src/main/env/dev</directory>
</resource>
</webResources>
</configuration>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
It generates both files (ReportsPortal.war and ReportsPortal-dev.war). Each one with its environment variables (and different between them).
When right clicking the ReportsPortal project and selecting Run, Netbeans starts the Tomcat and the application deployed has the correct values, so I guess it is using ReportsPortal-dev.war but I can't be sure.
My question:
How can I know or change the war file Netbeans is using to deploy in Tomcat?
You should create a separate maven build profile for each of the war files. You can then invoke the development profile while you are doing your dev work and leave the production profile to be called only when you want to make a release. This will allow you to control exactly what is getting built.
I am trying to integrate the generation of an installer as part of a maven compilation process.
I have found Alakai's plugin for Launch4j. I have create a simple Hello World application using Maven. I have tried to use configuration examples provided by Alakai, but when I compile my project, I get:
Failed to execute goal
org.bluestemsoftware.open.maven.plugin:launch4j-plugin:1.5.0.0:launch4j
(launch4j) on project Launch4j: Failed
to build the executable; please verify
your configuration. Application jar
doesnt exist. -> [Help 1]
Unfortunately, Alakai's documentation is limited and I could not find much with Googling.
Does anyone know where the Launch4j config.xml should be set? Is it within the project? Is it in a separate directory?
Do I need to use the assembly plugin?
I have installed Launch4j on my PC. Do I need to specify the installation directory in my pom.xml? If yes how?
Does anyone have an operational pom.xml sample/example to share?
Thanks.
There's no config.xml, you need to configure launch4j inside your pom.xml file.
You could use maven-assembly-plugin, but I recommend you to use maven-shade-plugin.
Don't need to specify launch4j installation, this plugin works 100% maven.
Sure. Follows the shade and launch4j configs I use, that generates two exes, one console and one gui, using different main classes:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached> <!-- Make the shaded artifact not the main one -->
<shadedClassifierName>shaded</shadedClassifierName> <!-- set the suffix to the shaded jar -->
</configuration>
</plugin>
<plugin>
<groupId>org.bluestemsoftware.open.maven.plugin</groupId>
<artifactId>launch4j-plugin</artifactId>
<version>1.5.0.0</version>
<executions>
<!-- GUI exe -->
<execution>
<id>l4j-gui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<outfile>target/app-gui.exe</outfile>
<jar>target/${artifactId}-${version}-shaded.jar</jar> <!-- 'shaded' is the value set on shadedClassifierName above -->
<errTitle>App Err</errTitle>
<classPath>
<mainClass>package.AppGUI</mainClass>
</classPath>
<icon>src/main/resources/icons/exeIcon.ico</icon>
<jre>
<minVersion>1.5.0</minVersion>
<maxVersion>1.6.0</maxVersion>
<initialHeapSize>128</initialHeapSize>
<maxHeapSize>1024</maxHeapSize>
</jre>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>1.0.0.0</txtFileVersion>
<fileDescription>Desc</fileDescription>
<copyright>C</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>1.0.0.0</txtProductVersion>
<productName>Product</productName>
<internalName>Product</internalName>
<originalFilename>App.exe</originalFilename>
</versionInfo>
</configuration>
</execution>
<!-- Command-line exe -->
<execution>
<id>l4j-cli</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>console</headerType>
<outfile>target/app-cli.exe</outfile>
<jar>target/${artifactId}-${version}-shaded.jar</jar> <!-- 'shaded' is the value set on shadedClassifierName above -->
<errTitle>App Err</errTitle>
<classPath>
<mainClass>package.AppCLI</mainClass>
</classPath>
<icon>src/main/resources/icons/exeIcon.ico</icon>
<jre>
<minVersion>1.5.0</minVersion>
<maxVersion>1.6.0</maxVersion>
<initialHeapSize>128</initialHeapSize>
<maxHeapSize>1024</maxHeapSize>
</jre>
</configuration>
</execution>
</executions>
</plugin>
Alternatively, You can omit the 'jar' tag on launch4j-plugin and remove the extra configs of the shade-plugin, but be aware that this will replace the main jar of the flow (without embedded dependencies) by the shaded jar (with embedded dependencies), and this one will be installed on your local repo, or used in the reactor if needed.
For how to define the main class for the shade plugin, see http://maven.apache.org/plugins/maven-shade-plugin/examples/executable-jar.html.