Setting a custom icon on javafx application - maven

I'm trying to build a native bundle on macos and add a custom icon instead of default java.
I put my 128x128 icns file in src/main/deploy/package/macosx, add javafx-maven-plugin in pom.xml and run command mvn jfx:build-native (or mvn jfx:native). And nothing happens. Meaning it is successfully built, but still uses default icon. What am I'm doing wrong?
Here is my pom.xml:
<?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>StarWars</groupId>
<artifactId>Minesweeper</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>example.minesweeper.Main</mainClass>
<application.title>${project.artifactId}</application.title>
<copyright>Han Solo</copyright>
</properties>
<organization>
<name>Star Wars</name>
</organization>
<name>Minesweeper</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-core</artifactId>
<version>4.0.6-alpha</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-junit</artifactId>
<version>4.0.6-alpha</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<vendor>AndreySerebryanskiy</vendor>
<mainClass>example.minesweeper.Main</mainClass>
<deployDir>${project.basedir}/src/main/deploy</deployDir>
</configuration>
</plugin>
</plugins>
</build>
</project>
And here is a screenshot of my project structure.
By the way, I'm using IntelliJ IDEA 2017.1.4. I also have seen this range of questions:
JavaFX native bundle icon OS X
including an icon into a self-contained JavaFX application (.exe)
I also tried to put package/macosx in the project folder but it didn't work.
How to set custom icon for javafx native package icon on Windows
I also saw a simple way of accomplishing this task in NetBeansIDE (for example here). But I do not want to change IDE because of such simple issue.
Thank you in advance!
Edit 31.07
After turning verbose mode on I found that it was expecting Minesweeper-1.0.icns instead of Minesweeper.icns. Adding appName field in conficurations of javafx-maven-plugin solved my problem.

You will have to add to your javafx-maven-plugin configuration.
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<vendor>AndreySerebryanskiy</vendor>
<mainClass>example.minesweeper.Main</mainClass>
<deployDir>${project.basedir}/src/main/deploy</deployDir>
<verbose>true</verbose><!-- always a good idea to have this set to true while debugging -->
<appName>Minesweeper</appName>
</configuration>
</plugin>
Please make sure your ICNS-filename is the same as inside <appName>, then just call mvn jfx:native to have your application bundled.

Related

Testng-Xslt reports are not getting generated

I have gone through many posts and blogs but couldn't generate reportng or testng-xslt reports via maven. Finally I have got this tutorial but no luck. I cant understand what am I missing.
Here's what I have tried : It successfully generates the surefire reports in the target folder but does"nt create(generate reports) a directory for reportng reports.Following is my Pom.xml file.
<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>tiger</groupId>
<artifactId>SampleProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SampleProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.6</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<reporting>
<plugins>
<!-- TestNG-xslt related configuration. -->
<plugin>
<groupId>org.reportyng</groupId>
<artifactId>reporty-ng</artifactId>
<version>1.2</version>
<configuration>
<!-- Output directory for the testng xslt report -->
<outputDir>/target/testng-xslt-report</outputDir>
<sortTestCaseLinks>true</sortTestCaseLinks>
<testDetailsFilter>FAIL,SKIP,PASS,CONF,BY_CLASS</testDetailsFilter>
<showRuntimeTotals>true</showRuntimeTotals>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
Looks like they have removed reporty-ng plugin from maven repository, so you may not be able to generate xslt report directly through maven.
If you want to generate XSLT reports you can take help of Ant XSLT
If you don't like the default report for any reasons, you can write your own one by implementing IReporter:
http://testng.org/doc/documentation-main.html#logging
I believe you are using below
<pluginRepositories>
<pluginRepository>
<id>reporty-ng</id>
<url>https://github.com/cosminaru/reporty- ng/raw/master/dist/maven</url>
Url is not working. They have removed it from that URL. However, I think you can use this URL https://github.com/prashanth-sams/testng-xslt-1.1.2/tree/master/src/main/java/org/testng/xslt/mavenplugin . I haven't tried it though.
You can download it from. https://drive.google.com/drive/folders/0B5v_nInLNoquV1p5YWtHc3lkUkU

Using a variable in Maven from the super pom

I am giving myself a crash course in Maven and stumbled across a great plugin called buildnumber: http://www.mojohaus.org/buildnumber-maven-plugin/create-mojo.html
I have setup a VERY rudimentary, beginners project and in the pom.xml file I am successfully having the ${buildNumber} to interpolate.
I have the pom.xml below (I apologize for the length of it).
<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>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<scm>
<connection>scm:git:ssh://git#bitbucket.org/XXXX/bb101repo.git</connection>
<developerConnection>scm:git:ssh://git#bitbucket.org/XXX/bb101repo.git</developerConnection>
<url>https://bitbucket.org/XXXX/bb101repo.git</url>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<shortRevisionLength>5</shortRevisionLength>
<!-- doCheck : Check for locally modified files. If true build will fail if local modifications have not been commited -->
<!-- doUpdate : Update the local copy of your repo. If true the plugin will update your local files with the remote modifications before building -->
<doCheck>true</doCheck>
<doUpdate>false</doUpdate>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}-${project.version}-${buildNumber}</finalName>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
When I run mvn package, it works as intended.
I have another file in my project (under src) called info.xml and it's below.
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>FMS Help</display-name>
<version>${buildNumber}</version>
</web-app>
How do I get the ${buildNumber} to unpack in my tag under target?
I'm guessing it's a really simple solution, but I'm stumped. Again, I'm a complete n00b at Maven and any pointer in the right direction would be appreciated.
JW
You need to tell Maven to apply filtering to your resources. Check out the resources plugin documentation here:
http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
To avoid applying filtering to all your source files, you'd either need to set up the proper include/exclude paths or move the info.xml file to the resources directory.

How to download spring framework zip file [duplicate]

This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
SpringSource.org changed their site to http://spring.io
Does someone know how to get the latest build without Maven/github? from http://spring.io/projects
Please edit to keep this list of mirrors current
I found this maven repo where you could download from directly a zip file containing all the jars you need.
https://maven.springframework.org/release/org/springframework/spring/
https://repo.spring.io/release/org/springframework/spring/
Alternate solution: Maven
The solution I prefer is using Maven, it is easy and you don't have to download each jar alone. You can do it with the following steps:
Create an empty folder anywhere with any name you prefer, for example spring-source
Create a new file named pom.xml
Copy the xml below into this file
Open the spring-source folder in your console
Run mvn install
After download finished, you'll find spring jars in /spring-source/target/dependencies
<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>spring-source-download</groupId>
<artifactId>SpringDependencies</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>download-dependencies</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Also, if you need to download any other spring project, just copy the dependency configuration from its corresponding web page.
For example, if you want to download Spring Web Flow jars, go to its web page, and add its dependency configuration to the pom.xml dependencies, then run mvn install again.
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>

Getting Started with Maven + Jaxb project + IntellijIdea

I am complete new to IntellijIdea and i am looking for some step-by-step process to set up a basic project.
My project depends on Maven + Jaxb classes so i need a Maven project so that when i compile this project, the JAXB Objects are generated by Maven plugins. Now i started like this
I created a blank project say MaJa project
Added Maven Module to it
Added following settings in POM.XML
<?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>MaJa</groupId>
<artifactId>MaJa</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${basedir}/src/main/resource/api/MaJa</schemaDirectory>
<packageName>com.rimt.shopping.api.web.ws.v1.model</packageName>
<outputDirectory>${build.directory}</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
First of all, is it right settings ?
I tried clicking on Make/Compile 'MaJa' from Project > Right Click Menu and it didn't do anything.
I will be looking forward to yoru replies.
You must click not on Make/Compile 'MaJa'
1) You must choose one of maven Build Lifecycle phases here (not less then Compile).
2) Set path to maven in settings.
3) Add version for jaxb-api artifact
I add shiporder.xsd to directory /src/main/resource/api/MaJa and java classes were generated well
[jaxb2:xjc]
Generating source...
parsing a schema...
compiling a schema...
com\rim\shopping\api\web\ws\v1\model\ObjectFactory.java
com\rim\shopping\api\web\ws\v1\model\Shiporder.java

Why does maven not copy the properties files during the build process?

Nothing I've found has been able to help me solve this one specific case. I recently switched from a plain old java web app project (which was working) to a maven web project. I get the following runtime exception:
java.util.MissingResourceException: Can't find bundle for base name com.myapp.config, locale en
I am using Netbeans to create a JSF 2.0, Spring, and Hibernate web app. I have the following directory structure:
src\main\java\com\myapp Contains config.properties
src\main\resources Empty
target\myapp\WEB-INF\classes\com\myapp Contains compiled class files without config.properties
src\main\java\com\myapp Contains config.properties
Inspection of the WAR file in the target folder does not show any sign of the properties file so it's as if the Maven build plug-in is not copying over properties files. I know there is a tag you can place inside the pom but it didn't work for me. The link below mentions that the resources folder (empty for me) has its contents included during the build but if that is the case, how do you do it from Netbeans? I just want the properties file to be packaged with my war so it is accessible when it is deployed to the server.
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
pom.xml:
<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>com.myapp</groupId>
<artifactId>myapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>myapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>java.net</id>
<name>Repository hosting the Java EE 6 artifacts</name>
<url>http://download.java.net/maven/2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-hibernate3</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>net.authorize</groupId>
<artifactId>java-anet-sdk</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.15</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
<finalName>${artifactId}</finalName>
</build>
<profiles>
<profile>
<id>endorsed</id>
<activation>
<property>
<name>sun.boot.class.path</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- javaee6 contains upgrades of APIs contained within the JDK itself.
As such these need to be placed on the bootclasspath, rather than classpath of the
compiler.
If you don't make use of these new updated API, you can delete the profile.
On non-SUN jdk, you will need to create a similar profile for your jdk, with the similar property as sun.boot.class.path in Sun's JDK.-->
<compilerArguments>
<bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path}</bootclasspath>
</compilerArguments>
</configuration>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<properties>
<netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
</properties>
Maven doesn't copy resources from the java source tree by default, but you can get it do that by adding this to your pom.xml:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes><exclude>**/*.java</exclude></excludes>
</resource>
</resources>
</build>
Make sure you exclude the java source files.
From https://rogerkeays.com/how-to-change-mavens-default-resource-folder
What is your project's build path configured to be in Netbeans? You might try changing it to src/main/webapp/WEB-INF/classes. This way class files compiled from your src/main/java folder and any resources you have under src/main/resources should get included in the generated WAR. You would then be able to access your config.properties file if you place it under the src/main/resources folder.
You might also review any includes sections in your pom.xml and ensure you're not accidentally excluding something (if you explicitly include some things, you're likely implicitly excluding everything else).
By default maven will include all files under resources folder. If your properties files are not in the resource folder, then you need to include the following in the pom.xml file under the build section.
<build>
/* other tags like <plugins> goes here */
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
/* other tags like <plugins> goes here */
</build>
Try putting your config.properties under src\main\resources\com\myapp. I was able to test this on a local project. I'm running Maven 3.0.2.
Created a mvn sample project with the webapp archetype:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp
Created a directory at src/main/resources/com/foo and put a foo.properties file under it.
Ran a build:
mvn clean install
Then, when looking in the resulting target directory, the foo.properties file appears:
ls -al target/my-webapp/WEB-INF/classes/com/foo/
-rw-r--r-- 1 sblaes staff 4 Apr 2 22:09 foo.properties
You might try those steps on your machine. If that works, then start trying to simplify your POM above by removing things from it to see if it starts working. Trial and error is no fun, but I just don't see anything above that should be breaking it.
Huge gotcha for this:
when your resources are in "test/resources" (e.g. .properties files for tests)
maven doesn't copy them to target, so they're not in the classpath
Check whether your "packaging" is set to "pom" in the pom.xml:
<packaging>pom</packaging>
Fix is:
change your packaging to "jar" or "war" instead

Resources