Java 仅在Windows中运行的Pom.xml
这是我在pom.xml中运行脚本flip.cmd的配置:Java 仅在Windows中运行的Pom.xml,java,linux,windows,maven,pom.xml,Java,Linux,Windows,Maven,Pom.xml,这是我在pom.xml中运行脚本flip.cmd的配置: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <executions> <execution> <id>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>My test</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/flip.cmd</executable>
</configuration>
</execution>
</executions>
</plugin>
org.codehaus.mojo
execmaven插件
我的测试
生成源
执行官
${basedir}/flip.cmd
它在我的Windows PC中运行良好,问题是我应该能够在Linux中运行同样的程序
如何更改上述配置才能在Windows和Linux上运行?您必须在Linux shell中准备另一个脚本可执行文件(例如.*.sh),然后创建由操作系统激活的单独配置文件
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<build>
<plugins>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>My test</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/flip.cmd</executable>
</configuration>
</execution>
</executions>
</plugins>
</build>
</profile>
<profile>
<id>unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<build>
<plugins>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>My test</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/flip.sh</executable>
</configuration>
</execution>
</executions>
</plugins>
</build>
</profile>
窗户
窗户
org.codehaus.mojo
execmaven插件
我的测试
生成源
执行官
${basedir}/flip.cmd
unix
unix
org.codehaus.mojo
execmaven插件
我的测试
生成源
执行官
${basedir}/flip.sh
看起来不错。当你尝试在Linux上构建它时会发生什么?@Danio我猜flip.cmd
是一个批处理文件,所以它根本无法在Linux上工作。是的,这是正确的。这是Windows的批处理文件。但是,如果我改为使用*.sh,它将只在Linux中工作,而不会在Windows中工作。这是一个难题,您必须为Linux编写一个等价的脚本,并使用正确的路径指向它。