Proguard Configuration Issue - java

<?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>com.appstruts.poc</groupId>
<artifactId>StrutsMavenPOC</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>StrutsMavenPOC</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>6.0.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<configuration>
<obfuscate>true</obfuscate>
<includeDependency>true</includeDependency>
<options>
<option>-target 1.8</option>
<option>-ignorewarnings</option>
<option>-dontoptimize</option>
<option>-keepdirectories</option>
<option>-renamesourcefileattribute SourceFile</option>
<option>-keepparameternames</option>
<option>-keep public class com.appstruts.poc.Test2</option>
<!-- Here comes a lot of interface packages, public classes, etc as the last one -->
<!-- <option><![CDATA[
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
]]></option> -->
<option>-injar ${project.build.directory}/${project.build.finalName}.${project.packaging}</option>
<option>-outjar ${project.build.directory}/${project.build.finalName}-proguarded.${project.packaging}</option>
</options>
<addMavenDescriptor>false</addMavenDescriptor>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jsse.jar</lib>
</libs>
<proguardVersion>4.8</proguardVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
I am new to proguard,
I have some configuration issue to obfuscate the class files with web application
can you please help me on it.
The Problem is the class files are not generates in proguarded war in /WEB-INF/classes/ it is having full package but does't have .class files
The below is actual war snap
and the following is the proguarded war
Please excuse my bad english.

Related

Java web application with wildfly can't create Entity classes from database

The issue when I'm trying to create entity classes:
Error image
(Just got wildfly's example db connection, so I can't choose my db connection)
Versions:
Wildfly 26.1.2
Java mysql connector 8.0.23
Java EE 7 Web
Jdk 17
Netbeans 15
Xampp 7.4.29
Windows 10 :(
At Services -> Databases, the db connection test works with the above version of mysql connector
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>com.example</groupId>
<artifactId>mavenproject1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>mavenproject1</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.23</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I tried with more versions, but nothing works.

'No main manifest attribute' error with Maven

Here is my 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>com.codetriage.scraper</groupId>
<artifactId>codetriagescraper</artifactId>
<version>1.0-SNAPSHOT</version>
<name>codetriagescraper</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.3</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.Maven.plugins</groupId>
<artifactId>Maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.Maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.codetriage.scraper.App</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Mvn package is okey, but when i try to java -jar target/codetriagescraper-1.0-SNAPSHOT.jar it returns me "no main manifest attribute, in target/codetriagescraper-1.0-SNAPSHOT.jar". I have tried to add different plugins to make jar executable, but they all didn't work. By the way, when i package the project console show only default plugins were compiled.

How do I work correctly with profiles, classifiers and modules in Maven?

I'm trying to create a Maven configuration that supports the same code for two different environments. One environment is Java 6 with Seam, the other is Java 7 with JEE.
My project is a multi module project with a parent pom where I've configured two profiles. The interesting parts in the parent pom:
<profiles>
<profile>
<id>JDK7</id>
<properties>
<jdk.version>1.7</jdk.version>
<profile.classifier>with-beans-xml</profile.classifier>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>${profile.classifier}</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>JDK6</id>
<properties>
<jdk.version>1.6</jdk.version>
<profile.classifier>without-beans-xml</profile.classifier>
</properties>
<!-- Identical parts left out for brevity -->
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>${profile.classifier}</classifier>
<excludes>
<exclude>src/main/resources/META-INF/beans.xml</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
In a sub module of this pom I need to reference specific versions of other modules to be sure they are all using the same build version of Java and should contain or not contain beans.xml.
This is how I've done that:
<parent>
<groupId>commons</groupId>
<artifactId>parent-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>some-module</artifactId>
<dependencies>
<dependency>
<groupId>commons</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
<classifier>${profile.classifier}</classifier>
</dependency>
</dependencies>
The properties decalared above resolves just fine, but the dependency called core above contains references to other modules that contain the core functionality of the entire project.
The dependencies in core doesn't resolve when I import that module into other modules.
This is the dependency hierarchy I'm expecting:
- some-module
- core
- some-other-module
However, after adding core as a dependency to another module, I explicitly need to add some-other-module for it to be available too, i.e. some-other-module is not transitive from referencing core.
Am I going about this the wrong way? It works just fine with the different versions, just that I have to add them explicitly which I'd rather not to avoid confusion when other users are going to use this.
Updated
By request, here is the full parent pom and one of the modules that are experiencing the problems with transitive dependencies.
parent 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>se.commons</groupId>
<artifactId>healthcheck-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>healthcheck-parent-pom</name>
<modules>
<module>healthcheck-core</module>
<module>healthcheck-xsd</module>
<module>healthcheck-jms</module>
<module>healthcheck-db</module>
<module>healthcheck-filesystem</module>
<module>healthcheck-http</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.home>${JAVA_1_7_HOME}</java.home>
</properties>
<profiles>
<profile>
<id>JDK7</id>
<!-- <activation> -->
<!-- <activeByDefault>true</activeByDefault> -->
<!-- </activation> -->
<properties>
<!-- Build properties -->
<jdk.version>1.7</jdk.version>
<profile.classifier>with-beans-xml</profile.classifier>
<bom.version>2.0.0.R</bom.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>se.commons</groupId>
<artifactId>bom</artifactId>
<version>${bom.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>${profile.classifier}</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<effort>Default</effort>
<threshold>Default</threshold>
<xmlOutputDirectory>target/findbugs</xmlOutputDirectory>
<failOnError>true</failOnError>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<targetJdk>${jdk.version}</targetJdk>
<configuration>
<omitVisitors>FindReturnRef</omitVisitors>
</configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.15</version>
<executions>
<execution>
<goals>
<goal>checkstyle</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<configLocation>${basedir}/../src/site/checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<dependencies>
<dependency>
<!-- add support for ssh/scp -->
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<configuration>
<locales>sv</locales>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>JDK6</id>
<properties>
<!-- Build properties -->
<jdk.version>1.6</jdk.version>
<profile.classifier>without-beans-xml</profile.classifier>
<bom.version>2.0.0.R</bom.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>se.commons</groupId>
<artifactId>bom</artifactId>
<version>${bom.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<resources>
<resource>
<directory>src/main/resources/META-INF</directory>
<excludes>
<exclude>beans.xml</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>${profile.classifier}</classifier>
<excludes>
<exclude>src/main/resources/META-INF/beans.xml</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<effort>Default</effort>
<threshold>Default</threshold>
<xmlOutputDirectory>target/findbugs</xmlOutputDirectory>
<failOnError>true</failOnError>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<targetJdk>${jdk.version}</targetJdk>
<configuration>
<omitVisitors>FindReturnRef</omitVisitors>
</configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.15</version>
<executions>
<execution>
<goals>
<goal>checkstyle</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<configLocation>${basedir}/../src/site/checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<dependencies>
<dependency><!-- add support for ssh/scp -->
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<configuration>
<locales>sv</locales>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<effort>Default</effort>
<threshold>Default</threshold>
<xmlOutputDirectory>target/findbugs</xmlOutputDirectory>
<failOnError>true</failOnError>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<targetJdk>${jdk.version}</targetJdk>
<configuration>
<omitVisitors>FindReturnRef</omitVisitors>
</configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.4</version>
<configuration>
<targetJdk>${jdk.version}</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<reportSets>
<reportSet>
<reports>
<report>cobertura</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<instrumentation>
</instrumentation>
<formats>
<format>xml</format>
<format>html</format>
</formats>
<instrumentation>
<includes>
<include>**/*.class</include>
</includes>
</instrumentation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
</plugin>
</plugins>
</reporting>
</project>
And here is one of the modules that use core as a dependency:
<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>
<parent>
<groupId>se.commons</groupId>
<artifactId>healthcheck-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>healthcheck-jms</artifactId>
<dependencies>
<dependency>
<groupId>se.commons</groupId>
<artifactId>healthcheck-core</artifactId>
<version>${project.version}</version>
<classifier>${profile.classifier}</classifier>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.jms</groupId>
<artifactId>jboss-jms-api_1.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
And finally, here is the pom of core:
<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>
<parent>
<groupId>se.commons</groupId>
<artifactId>healthcheck-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>healthcheck-core</artifactId>
<dependencies>
<dependency>
<groupId>se.commons</groupId>
<artifactId>healthcheck-xsd</artifactId>
<version>${project.version}</version>
<classifier>${profile.classifier}</classifier>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I finally gave up on the above solution after finding similar questions that never got a clear answer.
It doesn't seem to be possible to resolve transitive dependencies using a classifier, only the standard GAV.
I settled on a different artifactId to differentiate the projects instead.

Compile C to native library in Maven

I have a Java project that relies on C source files. I have the proper JNI header files, I just need to compile them with the C code to a dll (or Linux/OSX equivalent) in target/. My current pom.xml builds the Java code, but doesn't build the dll.
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.jadonfowler</groupId>
<artifactId>o</artifactId>
<packaging>jar</packaging>
<version>2.0</version>
<properties>
<!-- Native compiler -->
<compiler-name>clang</compiler-name>
<linker-name>clang</linker-name>
</properties>
<dependencies>
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-jdbc</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>src</testSourceDirectory>
<resources>
<resource>
<directory>res</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<optimize>true</optimize>
<debug>true</debug>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>xyz.jadonfowler.o.WebIDE</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>xyz.jadonfowler.o.WebIDE</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.alexkasko.maven</groupId>
<artifactId>jni-headers-maven-plugin</artifactId>
<version>1.0.6</version>
<executions>
<!-- generate header for native methods -->
<execution>
<id>javah</id>
<phase>compile</phase>
<goals>
<goal>javah</goal>
</goals>
<configuration>
<javahClass>xyz.jadonfowler.o.OCBindings</javahClass>
<javahOutputFilePath>${project.basedir}/xyz_jadonfowler_o_OCBindings.h</javahOutputFilePath>
</configuration>
</execution>
<!-- generate header for java methods -->
<!-- Not need atm
<execution>
<id>javap</id>
<phase>compile</phase>
<goals>
<goal>javap</goal>
</goals>
<configuration>
<javapClass>xyz.jadonfowler.o.OCBindings</javapClass>
<javapOutputFilePath>${project.basedir}/my_header_callbacks.h</javapOutputFilePath>
</configuration>
</execution> -->
</executions>
</plugin>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<c>
<name>${compiler-name}</name>
<debug>false</debug>
<includes>
<include>*.h</include>
<include>*.c</include>
</includes>
<!-- Options for compiler -->
<options combine.children="append">
<option>-I $JAVA_HOME</option>
<option>-I $JAVA_HOME/*</option>
</options>
</c>
<linker>
<name>${linker-name}</name>
</linker>
<libraries>
<library>
<type>jni</type>
<narSystemPackage>xyz.jadonfowler.o</narSystemPackage>
</library>
</libraries>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>windows-common</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<cpp>
<options combine.children="append">
<option>-mthreads</option>
</options>
</cpp>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>linux-common</id>
<activation>
<os>
<family>linux</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<cpp>
<options combine.children="append">
<option>-pthread</option>
</options>
</cpp>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
I'm using Java 8 with Clang. I have the jni-headers-maven-plugin, but I don't think I need it because I don't need to generate the headers on-the-fly. I also have the nar-maven-plugin, which I think is configured correctly, but it isn't showing up in the log anywhere.

Error Build in maven [duplicate]

This question already has an answer here:
Error in Maven building?
(1 answer)
Closed 9 years ago.
I wrote
mvn -f pom.xml compile exec:java -Dexec.classpathScope=Compile-Dexec.main Class=storm.starter.WordCountTopology
Here this the error
[INFO] One or more required plugin parameters are invalid/missing for 'exec:java'
here's what's in the pom.xml
<project 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>storm.starter</groupId>
<artifactId>storm-starter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>storm-starter</name>
<url>https://github.com/nathanmarz/storm-starter</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>github-releases</id>
<url>http://oss.sonatype.org/content/repositories/github-releases/</url>
</repository>
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert-core</artifactId>
<version>2.0M8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock</artifactId>
<version>2.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>storm</groupId>
<artifactId>storm</artifactId>
<version>0.9.0.1</version>
<!-- keep storm out of the jar-with-dependencies-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>15.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/jvm</sourceDirectory>
<testSourceDirectory>test/jvm</testSourceDirectory>
<resources>
<resource>
<directory>${basedir}/multilang</directory>
</resource>
</resources>
<plugins>
<!-- Bind the maven-assembly-plugin to the package phase this will create a jar file without the storm dependencies suitable for deployment to a cluster.-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass/>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.theoryinpractise</groupId>
<artifactId>clojure-maven-plugin</artifactId>
<version>1.3.12</version>
<extensions>true</extensions>
<configuration>
<sourceDirectories>
<sourceDirectory>src/clj</sourceDirectory>
</sourceDirectories>
</configuration>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<includeProjectDependencies>true</includeProjectDependencies>
<includePluginDependencies>false</includePluginDependencies>
<classpathScope>compile</classpathScope>
<mainClass>${storm.topology}</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
How does your POM look like? You need to include the Exec-plugin, so that your POM will look like something like this:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
...
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>maven</executable>
<!-- optional -->
<workingDirectory>/tmp</workingDirectory>
<arguments>
<argument>-X</argument>
<argument>myproject:dist</argument>
...
</arguments>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
(Source)

Categories