我试图根据使用配置文件的操作系统生成不同的工件,但当我运行mvn validate时,它给了我以下错误
- 无法识别的标签:'profiles' (position: START_TAG) r n ...C:test-apppom.xml,第33行,第19列
- 未知包装:nar @第15行,第16列
我的POM.xml如下所示。nar-maven-plugin在两个操作系统之间是通用的。
我不知道这里有什么问题。如有任何帮助,我将不胜感激。
<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>
试试这个-
<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>