linux maven vs mac maven

linux maven vs mac maven,linux,macos,maven,operating-system,Linux,Macos,Maven,Operating System,我们正在Linux机器和Mac机器上使用相同的pom.xml处理一个多模块maven项目,我们在脱机模式下运行下面的命令 mvn安装程序:运行-o 问题是maven为同一pom.xml文件下载了不同版本的插件。这里列出了区别 我们没有在pom.xml中指定插件的版本 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="ht

我们正在Linux机器和Mac机器上使用相同的pom.xml处理一个多模块maven项目,我们在脱机模式下运行下面的命令

mvn安装程序:运行-o

问题是maven为同一pom.xml文件下载了不同版本的插件。这里列出了区别

我们没有在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.test</groupId>
    <artifactId>Testing</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.1</version>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>Test</id>
                        <phase>install</phase>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <configuration>
                            <groupId>test.mac_linux</groupId>
                            <artifactId>Test</artifactId>
                            <version>1.0</version>
                            <file>${home_dir}/Downloads/jackson-databind-2.4.4.jar</file>
                            <packaging>jar</packaging>
                            <generatePom>true</generatePom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <configuration>
                    <phase>install</phase>
                    <target>
                        <zip destfile="${home_dir}/linux_mac_testing_maven/Testing_mac.zip">
                            <fileset dir="${home_dir}/.m2/repository/" includes="**/*" />
                        </zip>
                    </target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>copy-resources-WEB_INF</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${home_dir}/linux_mac_testing_maven/Resources/</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${home_dir}/CustomReport_files/</directory>
                                    <includes>
                                        <include>**.*</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

4.0.0
com.test
测试
1
罐子
org.apache.maven.plugins
maven安装插件
2.5.1
假的
试验
安装
安装文件
test.mac_linux
试验
1
${home_dir}/Downloads/jackson-databind-2.4.4.jar
罐子
真的
org.apache.maven.plugins
maven jar插件
3.1.0
org.apache.maven.plugins
maven antrun插件
1.7
安装
maven资源插件
3.0.2
copy-resources-WEB\u-INF
验证
复制资源
${home\u dir}/linux\u mac\u testing\u maven/Resources/
${home\u dir}/CustomReport\u文件/
**.*

有人知道为什么maven在使用不同的操作系统时会有不同的特性吗?

您在文章中提到,您使用的是不同版本的maven(Mac上是3.5,Linux上是3.3.9)。请将两者更新到最新版本(3.5.4),然后比较结果。

删除maven install plugin的配置,因为给定的jar文件可从maven central获得。这可以通过将其定义为依赖项来实现……删除maven antrun插件的使用,因为创建zip存档可以使用maven assembly plugin完成。。此外,maven resources插件的配置没有意义,因为如果这是一个WAR项目,您应该使用打包WAR等等……除此之外,mac和linux两者都是基于linux的,并且您使用的是Java,这不应该是一个问题?