Reputation: 878
I am trying to generate different artifacts based on OS used using profiles but when I run mvn validate, it gives me following errors
My POM.xml is given below. nar-maven-plugin is common between two OS.
I could not figure out what is the issue here. Any help would be highly appreciated.
<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>
<parent>
<groupId>com.company</groupId>
<artifactId>mvn-test</artifactId>
<version>1.0</version>
</parent>
<groupId>com.company.mvn-test</groupId>
<artifactId>test-app</artifactId>
<packaging>nar</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<skipTests>true</skipTests>
</properties>
<dependencies>
<dependency>
<groupId>com.company.mvn-test</groupId>
<artifactId>test-library</artifactId>
<type>nar</type>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<defaultGoal>integration-test</defaultGoal>
<profiles>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<libraries>
<library>
<type>executable</type>
<run>true</run>
</library>
</libraries>
<linker>
<name>g++</name>
</linker>
</configuration>
</plugin>
</plugins>
<profile>
<id>OS1</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<copy todir="bin" flatten="true">
<fileset dir="target">
<include name="**/*dll"/>
</fileset>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</profile>
<profile>
<id>OS2</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<copy todir="bin" flatten="true">
<fileset dir="target">
<include name="**/*so"/>
<include name="**/*test-app"/>
</fileset>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</profile>
</profiles>
</build>
Upvotes: 3
Views: 1215
Reputation: 64
Try this -
<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>
<parent>
<groupId>com.company</groupId>
<artifactId>mvn-test</artifactId>
<version>1.0</version>
</parent>
<groupId>com.company.mvn-test</groupId>
<artifactId>test-app</artifactId>
<packaging>nar</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<skipTests>true</skipTests>
</properties>
<dependencies>
<dependency>
<groupId>com.company.mvn-test</groupId>
<artifactId>test-library</artifactId>
<type>nar</type>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<defaultGoal>integration-test</defaultGoal>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<libraries>
<library>
<type>executable</type>
<run>true</run>
</library>
</libraries>
<linker>
<name>g++</name>
</linker>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>OS1</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<copy todir="bin" flatten="true">
<fileset dir="target">
<include name="**/*dll"/>
</fileset>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>OS2</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<copy todir="bin" flatten="true">
<fileset dir="target">
<include name="**/*so"/>
<include name="**/*test-app"/>
</fileset>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Upvotes: 1