maven rpm package fails with "ERROR!!!!SGSBASE value is not set.Hence exitting" - rpm-maven-plugin

I am tring to generate a simple rpm, but rpm goal fails with the following error
[INFO] --- rpm-maven-plugin:2.1x:rpm (default) # private ---
[INFO] Creating spec file C:\apps\eclipse\workspaces\algo-ws-new\private\target\rpm\SPECS\private.spec
SHARDA. in buildPackage....
ERROR!!!!SGSBASE value is not set.Hence exitting
here is the plugin config
<build>
<plugins>
<!-- create RPM -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.1x</version>
<extensions>true</extensions>
<executions>
<execution>
<phase>package</phase>
<configuration>
<copyright>2012</copyright>
<distribution>myproj</distribution>
<group>System</group>
<packager>Internal</packager>
<version>1.0</version>
<release>1.0.1</release>
<prefix>/opt/myproj</prefix>
<mappings>
</mappings>
</configuration>
<goals>
<goal>rpm</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Java version: 1.6.0_27, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_27\jre
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows xp", version: "5.1", arch: "x86", family: "windows"

seems the issue is that the rpm-maven-plugin is a company specific interanl 'enhanced' version
will work with the original version

Related

Proguard with JDK 10 / JDK 11 and maven pugin

Ho do I run Proguard with JDK 10 / JDK 11 and setup maven plugin?
Migration issues concerning OpenJDK 11 & OpenJFX 11 (& Proguard)
First of all, Proguard 6.0.3 does not run on Java 11 yet
(#188 Support Java 11, see https://sourceforge.net/p/proguard/feature-requests/188/).
Your sources can be compiled with JDK 11. For proguard plugin we have to use JDK 10.
In maven-compiler-plugin, set version to JDK 10:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>10</source>
<target>10</target>
<compilerArgs>
<arg>--add-modules=[required modules]</arg>
</compilerArgs>
</configuration>
</plugin>
Property for JDK 10 (OpenJDK is fine):
<properties>
<java.home.openjdk10>[pathtoJDK20]\jdk-10.0.2</java.home.openjdk10>
</properties>
proguard-maven-plugin:
<plugin>
<groupId>com.github.dingxin</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<id>process-classes-with-proguard</id>
<phase>test</phase>
<goals>
<goal>proguard</goal>
</goals>
<configuration>
<options>
<option>[proguarg options]</option>
</options>
<libs>
<lib>${java.home.openjdk10}/lib/jrt-fs.jar</lib>
<lib>${java.home.openjdk10}/jmods/java.base.jmod(!.jar;!module-info.class)</lib>
<lib>${java.home.openjdk10}/jmods/java.compiler.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.corba.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.datatransfer.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.desktop.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.instrument.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.logging.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.management.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.management.rmi.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.naming.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.prefs.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.rmi.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.scripting.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.se.ee.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.se.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.security.jgss.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.security.sasl.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.smartcardio.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.sql.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.sql.rowset.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.transaction.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.xml.bind.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.xml.crypto.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.xml.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.xml.ws.annotation.jmod</lib>
<lib>${java.home.openjdk10}/jmods/java.xml.ws.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.accessibility.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.aot.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.attach.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.charsets.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.compiler.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.crypto.cryptoki.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.crypto.ec.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.crypto.mscapi.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.dynalink.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.editpad.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.hotspot.agent.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.httpserver.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.incubator.httpclient.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.ed.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.jvmstat.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.le.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.opt.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.vm.ci.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.vm.compiler.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.internal.vm.compiler.management.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jartool.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.javadoc.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jcmd.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jconsole.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jdeps.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jdi.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jdwp.agent.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jlink.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jshell.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jsobject.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.jstatd.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.localedata.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.management.agent.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.management.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.naming.dns.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.naming.rmi.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.net.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.pack.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.rmic.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.scripting.nashorn.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.scripting.nashorn.shell.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.sctp.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.security.auth.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.security.jgss.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.unsupported.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.xml.bind.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.xml.dom.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.xml.ws.jmod</lib>
<lib>${java.home.openjdk10}/jmods/jdk.zipfs.jmod</lib>
</libs>
</configuration>
</execution>
</executions>
</plugin>

Apache maven plugin upgrade

I've seen here (https://issues.apache.org/jira/browse/MJARSIGNER-17) that the Maven Jar Signer Plugin has a new version which solves the proxy issue.
In Ubuntu 14.04, I have Maven installed
> uname -a
Linux jenkins 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
> mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/share/maven3
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.19.0-25-generic", arch: "amd64", family: "unix"
My pom.xml is here: /var/lib/jenkins/workspace/DEV-Snooper
How can I tell to MAVEN to download the latest version of the plugin and using it?
Thanks!
Riccardo
** EDIT: moved to Maven 3.3.9 ***
** Edit: my pom.xml **
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
...
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.4</version>
...
</plugin>
...
</plugins>
</build>
First of all, (my personal recommendation) -- consider upgrading to the latest Maven (3.3.9).
Secondly, the answer to your question: in your pom.xml (or respective parent pom.xml) define the version of the maven-jar-plugin:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
...
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.4</version>
</plugin>
</plugins>
</build>
...
</project>

Missing tools.jar for apt-maven-plugin on Ubuntu Java 8

I'm upgrading a maven project to compile with Java 8 from Java 7.
The installed java versions on my machine are
pauloconnell#pauloconnell-HP-ZBook-15:~/$ update-java-alternatives -l
java-7-oracle 1076 /usr/lib/jvm/java-7-oracle
java-8-oracle 1077 /usr/lib/jvm/java-8-oracle
And my JAVA_HOME is set
pauloconnell#pauloconnell-HP-ZBook-15:~/$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle
Any these are the details in my .bashrc file
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export MAVEN_HOME=/usr/share/maven/bin
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin
When i run 'mvn compile' on a module with this plugin
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>apt-maven-plugin</artifactId>
<configuration>
<factory>com.infonova.om.il.apt.Factory</factory>
<showWarnings>true</showWarnings>
</configuration>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
</plugin>
I get
[ERROR] Failed to execute goal org.codehaus.mojo:apt-maven-plugin:1.0-alpha-5:process (default) on project om-interface-eircom: Unable to locate the apt compiler in:
[ERROR] /usr/lib/jvm/java-8-oracle/jre/../lib/tools.jar
[ERROR] Please ensure you are using JDK 1.5 or above and
[ERROR] not a JRE (the com.sun.tools.apt.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
I found these existing issues
http://stackoverflow.com/questions/8375423/missing-artifact-com-suntoolsjar
https://github.com/thickpaddy/jenkins_campfire_plugin/issues/12
http://stackoverflow.com/questions/10812668/unable-to-locate-the-javac-compiler
http://stackoverflow.com/questions/5730815/unable-to-locate-tools-jar
and updated my plugin config to include the tools as systemPath dependency
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>apt-maven-plugin</artifactId>
<configuration>
<factory>com.infonova.om.il.apt.Factory</factory>
<showWarnings>true</showWarnings>
</configuration>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</plugin>
but the problem presists. My maven version details are
pauloconnell#pauloconnell-HP-ZBook-15:~/$ mvn -version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_IE, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-63-generic", arch: "amd64", family: "unix"
I believe i jave the correct JAVA_HOME and PATHS set. Any ideas?

Why maven is using maven-compiler-plugin 2.0.2 instead 3.0?

I tried to build some maven project. It failed becasue maven used older java 1.3, and project is using generics. I knwo that I can overwrite maven-compiler-plugin version and source and target, but that's not the point.
Steps to reproduce
$ git clone https://github.com/DuLerWeil/netty-diameter && cd netty-diameter
$ mvn help:effective-pom
...
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
My settings:
$ mvn -v
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_72, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.16.0-28-generic", arch: "amd64", family: "unix"
$ printenv JAVA_HOME
/usr/lib/jvm/java-7-oracle
$ readlink -f $(type -p java)
/usr/lib/jvm/java-7-oracle/jre/bin/java
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.10
Release: 14.10
Codename: utopic
your JAVA_HOME needs to point to a JDK not a JRE. JDK is the Java Development Environment, only this one contains the javac executable (the compiler). The maven compiler plugin uses the javac compiler - it is not a compiler itself.
The compiler plugin has some configuration to define the java version too. See "source" and "target" in
http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html
a usage example can be found here: http://maven.apache.org/plugins/maven-compiler-plugin/usage.html - you can probably delete the execution configuration - since it looks like the defaults.

Compile Maven Module with Different Java Version

My maven project has a few modules: server, web, etc.
I would like to build all but my server module on Java 6. For the server module, I'd like to compile it with Java 7.
Here's my pom.xml below, but I think that if I modify it to 1.7, then all of my modules will be compiled with Java 7. Also, does maven use the JAVA_HOME environment variable to determine which Java version to use?
<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>
<memmax>2048m</memmax>
</configuration>
</plugin>
EDIT Also, does the below output of
maven --version
indicate that maven is compiling my java code with 1.7?
vagrant#dev:~/bin/apache-tomcat-7.0.29/bin$ mvn --version
Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
Maven home: /home/vagrant/bin/apache-maven-3.0.4
Java version: 1.7.0_07, vendor: Oracle Corporation
Java home: /home/vagrant/bin/jdk1.7.0_07/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-23-generic", arch: "amd64", family: "unix"
Thanks,
Kevin
There are a number of hacks out there for compiling source code with a different version of the JDK than you are using to run Maven, for example you can use something like
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<executable><!-- path-to-javac --></executable>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
The issue with this approach is that you now have hard-coded the path to the JDK into your POM. Everything will work just fine on your machine but when you have to rebuild your machine because the HDD failed, or when you want to build on a different machine, you will be stuck as the path will most likely not match up.
The correct best practice way to handle this is via Toolchains. This will see you creating a ~/.m2/toolchains.xml file that describes where each of the different toolchains in your system are. Then the version of the JDK can be applied by the Maven Toolchains Plugin, e.g.
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.6</version>
</jdk>
</toolchains>
</configuration>
</plugin>
...
</plugins>
The next thing is that you don't need this as often as you would think. For example by using the source and target values you can generate the correct bytecode for the JRE that you are targeting... the only issue that you will then hit is the use of methods that are new in JRE 1.7... which is where Mojo's Animal Sniffer Plugin comes in. Animal Sniffer can be used to ensure that you only use the methods of the JRE that you are targeting. The general community consensus is that the use of source and target configuration options in the Maven Compiler Plugin configuration coupled with the use of Mojo's Animal Sniffer virtually eliminates the need for toolchains on the Compiler end of things.... on the Surefire end of things there is still need for toolchains... and I have a few edge cases that I need to update the compiler plugin and the toolchains plugins for to handle but, realistically you will not hit those edge cases ;-)
Just to be sure that your original question is completely answered (since the above answers the question you wanted to ask - as opposed to the one you asked)
At present you are compiling with JDK 1.7 however depending on the version of the Maven Compiler Plugin you are using, you may be compiling with either <source>1.4</source><target>1.4</target> or <source>1.5</source><target>1.5</target> unless you have changed the configuration of the Maven Compiler Plugin in your pom.xml. That will dictate which language features are available to you, but not which classes... so you would be generating code that will work on JRE 1.7 and provided you have not used any new classes/methods introduced since 1.4/1.5 (Such as String.isEmpty()) should also work on JRE 1.4/1.5... the only way to be sure if it works on such an old JVM is to either: run it on the old JVM OR use Animal Sniffer.
Maven Toolchains
To use multiple Java versions, you need to use Maven Toolchains, which require you to create a toolchains.xml file in your ~/.m2 Maven folder, containing all Java versions installed on your machine:
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<id>Java13</id>
<version>13</version>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_13}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<id>Java9</id>
<version>9</version>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_9}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<id>Java8</id>
<version>8</version>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_8}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<id>Java7</id>
<version>7</version>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_7}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<id>Java6</id>
<version>6</version>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_6}</jdkHome>
</configuration>
</toolchain>
</toolchains>
The JAVA_HOME_13, JAVA_HOME_9, JAVA_HOME_8, JAVA_HOME_7, JAVA_HOME_6 environment variables are configured so that they reference the path where the associated Java version is installed.
The FlexyPool parent pom.xml configuration file
The parent pom.xml Maven configuration file of the FlexyPool project defines the global Java version settings
<properties>
<jdk.version>8</jdk.version>
...
</properties>
Now, we need to instruct both the compiler and the test plugins to use the configured java version.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>${jdk.version}</version>
</jdk>
</toolchains>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
</plugins>
</build>
The FlexyPool child Maven module pom.xml using a different Java version
The flexy-pool-core-java9 child Maven module that requires a different Java version only needs to override the default jdk.version Maven property:
<properties>
<jdk.version>9</jdk.version>
</properties>
And that's it, we can now build each module using its own minimum viable Java version.
use the setup for the JDK6 on your top pom, it will be inherited by all the module, and overwrite it for your server pom with the different configuration required.
As for the path of the JDK, you can specify it, see here: http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html

Resources