I'm using the latest gwt maven plugin (https://tbroyer.github.io/gwt-maven-plugin/index.html) to compile a multi module GWT project and deploy it to tomcat 9. I am also using intellij 14 as my IDE. It's a client app only ie. no server/servlet. When I build via the IDE gwt plugin and zip up and deploy that output to tomcat my app works fine.
However, using the maven plugin, everything compiles ok and the contents of the war look fine to me. The war deploys ok to tomcat, but I simply see a blank page when I try to load it on my browser (latest chrome edition).
I'm running dev tools and jscript console and there are no errors being reported, network view, shows the content downloading ok. I've set break points in my nocache js files and stepped through it with no problems. Below is my pom. I'd appreciated any insight / help with this as it's been bugging me for days..
<?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">
<parent>
<artifactId>guml-ui</artifactId>
<groupId>guml-ui</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dashboard</artifactId>
<!--<packaging>gwt-app</packaging>-->
<dependencies>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>myworkspace</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>project</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java/au/com/guml/ui/components/dashboard/public</directory>
</resource>
<resource>
<directory>war</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-9</version>
<extensions>true</extensions>
<configuration>
<moduleName>au.com.guml.ui.components.dashboard.Dashboard</moduleName>
<moduleShortName>Dashboard</moduleShortName>
<warDir>${basedir}/../gumlui-war/target/gumlui-war-${project.version}</warDir>
<devmodeWorkDir>${basedir}/../gumlui-war/target/gumlui-war-${project.version}</devmodeWorkDir>
<webappDirectory>${basedir}/../gumlui-war/target/gumlui-war-${project.version}</webappDirectory>
<skipModule>true</skipModule>
<draftCompile>true</draftCompile>
<startupUrls>Dashboard.html</startupUrls>
</configuration>
<executions>
<execution>
<id>compile-module-common</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.common.Common</moduleName>
<moduleShortName>Common</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-myworkspace</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.myworkspace.MyWorkspace</moduleName>
<moduleShortName>MyWorkspace</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-project</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.project.Project</moduleName>
<moduleShortName>Project</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-dashboard</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.dashboard.Dashboard</moduleName>
<moduleShortName>Dashboard</moduleShortName>
</configuration>
</execution>
</executions>
</plugin>
<!-- copy the host html page -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-hosthtml</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/../gumlui-war/target/gumlui-war-${project.version}</outputDirectory>
<resources>
<resource>
<directory>war</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-public</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/../gumlui-war/target/gumlui-war-${project.version}/Dashboard</outputDirectory>
<resources>
<resource>
<directory>src/main/java/au/com/guml/ui/components/dashboard/public</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Cheers,
Matt.
For anyone that is interested I got the maven build working on the multi module gwt project. See the following pom (dashboard) which is my app which inherits other modules.
<?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">
<parent>
<artifactId>guml-ui</artifactId>
<groupId>guml-ui</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dashboard</artifactId>
<!--<packaging>gwt-app</packaging>-->
<dependencies>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>myworkspace</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>project</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>guml-ui</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-sources</artifactId>
<version>4.1.0.Final</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/hibernate-validator-4.1.0.Final-sources.jar</systemPath>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java/au/com/guml/ui/components/dashboard/public</directory>
</resource>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-9</version>
<extensions>true</extensions>
<configuration>
<moduleName>au.com.guml.ui.components.dashboard.Dashboard</moduleName>
<moduleShortName>Dashboard</moduleShortName>
<warDir>${basedir}/../gumlui-war/target/gumlui</warDir>
<devmodeWorkDir>${basedir}/../gumlui-war/target/gumlui</devmodeWorkDir>
<webappDirectory>${basedir}/../gumlui-war/target/gumlui</webappDirectory>
<skipModule>true</skipModule>
<startupUrls>Dashboard.html</startupUrls>
<!--<style>PRETTY</style>-->
</configuration>
<executions>
<execution>
<id>compile-module-common</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.common.Common</moduleName>
<moduleShortName>Common</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-myworkspace</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.myworkspace.MyWorkspace</moduleName>
<moduleShortName>MyWorkspace</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-project</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.project.Project</moduleName>
<moduleShortName>Project</moduleShortName>
</configuration>
</execution>
<execution>
<id>compile-module-dashboard</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<moduleName>au.com.guml.ui.components.dashboard.Dashboard</moduleName>
<moduleShortName>Dashboard</moduleShortName>
</configuration>
</execution>
</executions>
</plugin>
<!-- copy the host html page -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-public</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/../gumlui-war/target/gumlui/Dashboard</outputDirectory>
<resources>
<resource>
<directory>src/main/java/au/com/guml/ui/components/dashboard/public</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have to include the build resources entries on this pom and my inherited projects to manually include the public directory, not sure why, this appears to a quirk with the plugin.
Related
I have an app that consists of two main modules: backend and frontend.
Backend is written in SpringBoot, with SpringMVC.
Frontend is Angular.
I would like to build the app and for all the frontend paths to have a prefix "/app-frontend" so that I can easily ignore them from the SpringBoot security configurations. How can I achieve this? What I have until now is the following:
fronent 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">
<parent>
<groupId>com.demo.app</groupId>
<artifactId>demo-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>demo-app-frontend</artifactId>
<packaging>jar</packaging>
<build>
<resources>
<resource>
<!-- we copy the content of the frontend directory in the final artifact -->
<directory>./dist/demo-app-frontend</directory>
<targetPath>static</targetPath>
</resource>
</resources>
<plugins>
<!-- clean the dist directory used by Angular -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>dist</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.11.2</version>
<configuration>
<workingDirectory>./</workingDirectory>
<nodeVersion>v14.18.0</nodeVersion>
<npmVersion>6.14.15</npmVersion>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run pipeline-build</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
backend pom.xml:
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>demo-app-frontend</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
</dependencies>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>merge</id>
<phase>initialize</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.demo.app</groupId>
<artifactId>demo-app-frontend</artifactId>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
The build passes and I can start UI by running the jar and accessing localhost:8080 but I do not know what changes I need to do for the UI to be accessible at localhost:8080/frontend-app
Within a larger Maven project, I have a Java file (AudioFileBuilder.java) that generates audio files from the Google Cloud Text-to-Speech service. It can execute from its own main() class; however, this file references an enumeration within the project (that other project source files depend on).
I am creating a fat JAR (JAR-with-dependencies), .exe file (Windows), and .app file (macOS) for the main project. I would like to exclude the AudioFileBuilder.java file AND the associated Google Cloud Text-to-Speech dependency in the JAR, exe, and app files. However, I still need the AudioFileBuilder.java file to run every time the project is built.
Here is a link to my project's current POM file (the project is open-source):
https://github.com/hadi16/GamesForTheBlind/blob/Alex-Branch/pom.xml
This is my current POM 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>edu.up</groupId>
<artifactId>Games_For_Blind</artifactId>
<version>1.0.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<packaging>jar</packaging>
<dependencies>
<!-- Compile Dependencies -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-texttospeech</artifactId>
<version>0.117.0-beta</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
<scope>compile</scope>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>12</source>
<target>12</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<outputDirectory>${project.build.directory}/dist</outputDirectory>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>gamesforblind.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-classes</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target/xsd-out</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- To generate the phrase audio files. -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>gamesforblind.synthesizer.AudioFileBuilder</argument>
</arguments>
<environmentVariables>
<GOOGLE_APPLICATION_CREDENTIALS>google_api_key.json</GOOGLE_APPLICATION_CREDENTIALS>
</environmentVariables>
</configuration>
</plugin>
<!-- Create executable Windows file. -->
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.7.25</version>
<executions>
<execution>
<id>l4j-clui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<jar>${project.build.directory}/dist/${project.artifactId}-${project.version}-jar-with-dependencies.jar</jar>
<outfile>${project.build.directory}/dist/${project.artifactId}-${project.version}.exe</outfile>
<classPath>
<mainClass>gamesforblind.Main</mainClass>
</classPath>
<jre>
<minVersion>12</minVersion>
<jdkPreference>preferJre</jdkPreference>
</jre>
<versionInfo>
<copyright>2019</copyright>
<fileVersion>${project.version}</fileVersion>
<txtFileVersion>${project.version}</txtFileVersion>
<fileDescription>${project.name}</fileDescription>
<productVersion>${project.version}</productVersion>
<txtProductVersion>${project.version}</txtProductVersion>
<productName>${project.name}</productName>
<internalName>${project.name}</internalName>
<originalFilename>${project.artifactId}-${project.version}.exe</originalFilename>
<companyName>University of Portland</companyName>
</versionInfo>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.perdian.maven.plugins</groupId>
<artifactId>macosappbundler-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<plist>
<CFBundleDisplayName>Games For The Blind</CFBundleDisplayName>
<JVMMainClassName>gamesforblind.Main</JVMMainClassName>
<JVMVersion>12</JVMVersion>
<CFBundleDisplayName>Games For The Blind</CFBundleDisplayName>
<CFBundleName>Games For The Blind</CFBundleName>
</plist>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
UPDATE:
I divided the project into two separate modules: "audio-builder" & "application" - as suggested by Welsh.
However, I have a Java enumeration ("Phrases.java") that both the audio-builder & application uses. The audio-builder needs this file to know which audio phrases are currently in the program, while the rest of the application needs this to load in said audio files & call the playback of these files.
So, this made me add the "audio-builder" module as a dependency for the "application" module. Since the Google Cloud dependency is needed at compile-time, this means that it is bundled in the generated JAR, app, and exe files.
These changes can be found here: https://github.com/hadi16/GamesForTheBlind/tree/Maven-Fixes
Root POM file:
<?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>edu.up</groupId>
<artifactId>games-for-the-blind</artifactId>
<version>1.0.0.0</version>
<modules>
<module>games-for-the-blind/audio-builder</module>
<module>games-for-the-blind/application</module>
</modules>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
Audio-builder POM file:
<?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>edu.up</groupId>
<artifactId>audio-builder</artifactId>
<version>1.0.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-texttospeech</artifactId>
<version>0.117.0-beta</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>12</source>
<target>12</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>builder.AudioFileBuilder</argument>
</arguments>
<environmentVariables>
<GOOGLE_APPLICATION_CREDENTIALS>google_api_key.json</GOOGLE_APPLICATION_CREDENTIALS>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
Application POM file (note the dependency to audio-builder):
<?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>edu.up</groupId>
<artifactId>application</artifactId>
<version>1.0.0.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- Compile Dependencies -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
<scope>compile</scope>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.up</groupId>
<artifactId>audio-builder</artifactId>
<version>1.0.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>12</source>
<target>12</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<outputDirectory>${project.build.directory}/dist</outputDirectory>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>gamesforblind.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-classes</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target/xsd-out</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Create executable Windows file. -->
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.7.25</version>
<executions>
<execution>
<id>l4j-clui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<jar>
${project.build.directory}/dist/${project.artifactId}-${project.version}-jar-with-dependencies.jar
</jar>
<outfile>${project.build.directory}/dist/${project.artifactId}-${project.version}.exe
</outfile>
<classPath>
<mainClass>gamesforblind.Main</mainClass>
</classPath>
<jre>
<minVersion>12</minVersion>
<jdkPreference>preferJre</jdkPreference>
</jre>
<versionInfo>
<copyright>2019</copyright>
<fileVersion>${project.version}</fileVersion>
<txtFileVersion>${project.version}</txtFileVersion>
<fileDescription>${project.name}</fileDescription>
<productVersion>${project.version}</productVersion>
<txtProductVersion>${project.version}</txtProductVersion>
<productName>${project.name}</productName>
<internalName>${project.name}</internalName>
<originalFilename>${project.artifactId}-${project.version}.exe</originalFilename>
<companyName>University of Portland</companyName>
</versionInfo>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.perdian.maven.plugins</groupId>
<artifactId>macosappbundler-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<plist>
<CFBundleDisplayName>Games For The Blind</CFBundleDisplayName>
<JVMMainClassName>gamesforblind.Main</JVMMainClassName>
<JVMVersion>12</JVMVersion>
<CFBundleDisplayName>Games For The Blind</CFBundleDisplayName>
<CFBundleName>Games For The Blind</CFBundleName>
</plist>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Thank you!
I would recommend that you split your projects into two sub projects, so you would have for example:
games-for-the-blind/
pom.xml
audio-builder/
pom.xml
application/
pom.xml
Then what you can do is have the audio-builder package output the required files into the application/resources directory and have it listed first in the main pom.xml file.
This would allow you to distribute the application resultant files that would not contain any of the details of the audio-builder project.
I am writing my groovy code in maven using GMaven plugin. when I do mvn clean install it is showing build success but when I checked my target folder it is not generating any jar for me. I am refering this atlassian link in that
<plugins>
<plugin>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
but for this I am getting pom error on execution. please help me out here
Below is my pom 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>com.myproject</groupId>
<artifactId>mydata</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mydata</name>
<url>http://maven.apache.orgurl>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gmaven.version>1.5</gmaven.version>
<groovy.version>2.1.8</groovy.version>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.11</version>
</dependency>
</dependencies>
<build>
<!-- <pluginManagement> -->
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>${gmaven.version}</version>
<configuration>
<providerSelection>2.0</providerSelection>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-2.0</artifactId>
<version>${gmaven.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
</dependency>
</dependencies>
<!-- <executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions> -->
</plugin>
</plugins>
<!-- </pluginManagement> -->
</build>
</project>
UPDATE 1:
I am able to see the jar but it does not have my groovy code
Can you please try the following:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>
<directory>${project.basedir}/src</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</source>
</sources>
</configuration>
</plugin>
Actually that's what I'm using and jar is correctly generated
PS: Make sure that source.directory points to where your .groovy files exist
I'm modifying Weka, an open-source Maven project, and my modifications are running perfectly on eclipse. However, when I export to an executable jar file, I get a null pointer exception, because it's not able to find the images I created and added to the project upon getImage() calls.
It seems that this is a rather common problem with jar files, so I tried using the URL method to load, but upon further investigation, when I look into the jar file with SecureZIP, the images(.png) that I added to the project are not even in the jar (however, the images (.png) that were in the original open source distribution were, despite the fact that all the images were in the same folder and of the same type (.png) designated by the build path in the source). Is there something I'm forgetting to do? Why are my images not exporting to the jar, but the other images in the folder are?
Library Handling is: "Extract required libraries into generated JAR".
Images are in src/main/java/weka/gui.
<?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>nz.ac.waikato.cms.weka</groupId>
<artifactId>weka-stable</artifactId>
<version>3.8.1-SNAPSHOT</version>
<!-- weka-version -->
<packaging>jar</packaging>
<name>weka-stable</name>
<description>The Waikato Environment for Knowledge Analysis (WEKA), a machine learning workbench. This is the stable version. Apart from bugfixes, this version does not receive any other updates.
</description>
<url>http://www.cms.waikato.ac.nz/ml/weka/</url>
<organization>
<name>University of Waikato, Hamilton, NZ</name>
<url>http://www.waikato.ac.nz/</url>
</organization>
<licenses>
<license>
<name>GNU General Public License 3</name>
<url>http://www.gnu.org/licenses/gpl-3.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>wekateam</id>
<name>The WEKA Team</name>
<email>wekalist#list.waikato.ac.nz</email>
</developer>
</developers>
<mailingLists>
<mailingList>
<name>wekalist</name>
<subscribe>https://list.waikato.ac.nz/mailman/listinfo/wekalist</subscribe>
<unsubscribe>https://list.waikato.ac.nz/mailman/listinfo/wekalist</unsubscribe>
<archive>https://list.waikato.ac.nz/mailman/htdig/wekalist/</archive>
</mailingList>
</mailingLists>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<scm>
<connection>scm:svn:https://svn.cms.waikato.ac.nz/svn/weka/branches/stable-3-8/weka</connection>
<developerConnection>scm:svn:https://svn.cms.waikato.ac.nz/svn/weka/branches/stable-3-8/weka</developerConnection>
<url>https://svn.cms.waikato.ac.nz/svn/weka/branches/stable-3-8/weka</url>
</scm>
<profiles>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- used for skipping tests -->
<id>no-tests</id>
<properties>
<skipTests>true</skipTests>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nz.ac.waikato.cms.weka.thirdparty</groupId>
<artifactId>java-cup-11b</artifactId>
<version>2015.03.26</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>nz.ac.waikato.cms.weka.thirdparty</groupId>
<artifactId>java-cup-11b-runtime</artifactId>
<version>2015.03.26</version>
</dependency>
<dependency>
<groupId>nz.ac.waikato.cms.weka.thirdparty</groupId>
<artifactId>bounce</artifactId>
<version>0.18</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.10</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.googlecode.matrix-toolkits-java</groupId>
<artifactId>mtj</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>net.sourceforge.f2j</groupId>
<artifactId>arpack_combined_all</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.netlib-java</groupId>
<artifactId>netlib-java</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<weka.main.class>weka.gui.GUIChooser</weka.main.class>
</properties>
<build>
<directory>dist</directory>
<outputDirectory>build/classes</outputDirectory>
<testOutputDirectory>build/testcases</testOutputDirectory>
<resources>
<resource>
<targetPath>${project.build.outputDirectory}</targetPath>
<directory>${project.build.sourceDirectory}</directory>
<includes>
<include>**/*.arff</include>
<include>**/*.cost</include>
<include>**/*.cup</include>
<include>**/*.default</include>
<include>**/*.excludes</include>
<include>**/*.flex</include>
<include>**/*.gif</include>
<include>**/*.icns</include>
<include>**/*.ico</include>
<include>**/*.jflex</include>
<include>**/*.jpeg</include>
<include>**/*.jpg</include>
<include>**/*.kfml</include>
<include>**/*.matrix</include>
<include>**/*.png</include>
<include>**/*.properties</include>
<include>**/*.props</include>
<include>**/*.txt</include>
<include>**/*.xml</include>
<include>**/DatabaseUtils.props.*</include>
<include>weka/gui/beans/README</include>
</includes>
</resource>
<resource>
<targetPath>${project.build.testOutputDirectory}</targetPath>
<directory>${project.build.testSourceDirectory}</directory>
<includes>
<include>**/*.arff</include>
<include>**/*.cost</include>
<include>**/*.cup</include>
<include>**/*.default</include>
<include>**/*.excludes</include>
<include>**/*.flex</include>
<include>**/*.gif</include>
<include>**/*.icns</include>
<include>**/*.ico</include>
<include>**/*.jflex</include>
<include>**/*.jpeg</include>
<include>**/*.jpg</include>
<include>**/*.kfml</include>
<include>**/*.matrix</include>
<include>**/*.png</include>
<include>**/*.properties</include>
<include>**/*.props</include>
<include>**/*.txt</include>
<include>**/*.xml</include>
<include>**/DatabaseUtils.props.*</include>
<include>weka/gui/beans/README</include>
</includes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<disableXmlReport>true</disableXmlReport>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<systemPropertyVariables>
<weka.test.Regression.root>src/test/resources/wekarefs</weka.test.Regression.root>
<weka.test.maventest>true</weka.test.maventest>
<user.timezone>Pacific/Auckland</user.timezone>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<tagBase>https://svn.cms.waikato.ac.nz/svn/weka/tags</tagBase>
<useReleaseProfile>false</useReleaseProfile>
<!-- tests are performed with the ant build file, hence skipped here. -->
<preparationGoals>clean verify -P no-tests</preparationGoals>
<goals>deploy -P no-tests</goals>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>.</directory>
<includes>
<include>**/*~</include>
<include>**/.attach_pid*</include>
<include>**/hs_err_pid*</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<manifest>
<mainClass>${weka.main.class}</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<excludeResources>true</excludeResources>
</configuration>
</execution>
<execution>
<id>attach-test-sources</id>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<maxmemory>1000m</maxmemory>
<subpackages>weka:org</subpackages>
<show>public</show>
<outputDirectory>${project.basedir}/doc</outputDirectory>
<!-- when using Java 8, use this setting to avoid overly strict javadoclet -->
<!--additionalparam>-Xdoclint:none</additionalparam-->
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have been searching for few hours how to build .jar with maven.
Finnaly i got it.
But now i have to have sources in src/main/java.
How to 'include' src/main/groovy to my project?
I read solution here but I really don't want to change my pom.xml. I had so many troubles with this.
Here is my 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>net.thornydev</groupId>
<artifactId>script</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>script</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.7.0-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>pl.jedro.Main</mainClass>
</transformer>
</transformers>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.0-beta-3</version>
</dependency>
</dependencies>
I tried with:
<sources>
<source>${basedir}/src/main/groovy</source>
</sources>
and
<build>
<resources>
<resource>
<directory>src/main/groovy</directory>
</resource>
</resources>
but still nothing.
I got :
Error: Could not find or load main class pl.jedro.Main
Finally got solution.
I added:
<sourceDirectory>src/main</sourceDirectory>
<resources>
<resource>
<directory>groovy</directory>
</resource>
</resources>
in <build> </build> section.