2017-06-23 36 views
1

我的团队有一个多模块Maven项目,使用Maven 3.3.9可以很好地构建,但在使用Maven 3.5.0时失败。在这两种情况下(即Maven版本),构建都使用java 8_131。这些故障发生在:MacOS Sierra 10.12.6和CENTOS 7.在两个版本的Maven下,单独的非多模块项目都可以正常工作。Maven 3.5.0抛出ArrayIndexOutOfBoundsException,但使用Maven构建3.3.9

我已经使用Maven CI友好版本文档更新了父代POM,其中flatten-maven-plugin。我已经检查了这里和其他地方的其他问题,但没有找到答案。还有另一个未解答的问题:这可能源于同一问题。

任何帮助确定问题将不胜感激。

的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.company</groupId> 
    <artifactId>company-api-parent-pom</artifactId> 
    <version>${revision}${changelist}</version> 
    <packaging>pom</packaging> 

    <properties> 
     <revision>0.9.7</revision> 
     <changelist>-SNAPSHOT</changelist> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <maven.compiler.source>1.8</maven.compiler.source> 
     <maven.compiler.target>1.8</maven.compiler.target> 

     <jetty.version>9.3.12.v20160915</jetty.version> 
     <jersey.version>2.23.2</jersey.version> 
     <spring.version>4.3.3.RELEASE</spring.version> 
     <slf4j.version>1.7.21</slf4j.version> 
     <logback-version>1.1.7</logback-version> 
     <metrics-version>3.1.2</metrics-version> 
     <apache-commons-lang3-version>3.5</apache-commons-lang3-version> 
     <junit.version>4.12</junit.version> 
     <mockito.version>2.0.42-beta</mockito.version> 
     <powermock.version>1.6.5</powermock.version> 
     <aspectj.version>1.8.9</aspectj.version> 
     <enunciate-plugin-version>2.8.0</enunciate-plugin-version> 
     <postgres.jdbc.driver.version>9.4.1211</postgres.jdbc.driver.version> 
     <mybatis.version>3.4.1</mybatis.version> 
     <mybatis.spring.version>1.3.0</mybatis.spring.version> 
     <c3p0.version>0.9.5.2</c3p0.version> 
     <commons.beanutils.version>1.9.3</commons.beanutils.version> 
     <aws.java.sdk.bom.version>1.11.123</aws.java.sdk.bom.version> 
     <hibernate.validator.version>5.3.1.Final</hibernate.validator.version> 
     <commons-validator.version>1.5.1</commons-validator.version> 
     <joda.time.version>2.9.5</joda.time.version> 
     <liquibase.version>3.5.3</liquibase.version> 
     <jolokia.version>1.3.5</jolokia.version> 
     <javax.el.version>2.2.4</javax.el.version> 
     <jackson.annotations.version>2.5.4</jackson.annotations.version> 
     <janino.version>3.0.6</janino.version> 
     <open.csv.version>3.9</open.csv.version> 
     <jedis.version>2.9.0</jedis.version> 
    </properties> 

    <modules> 
     <module>company-api-app</module> 
     <module>company-api-java-client</module> 
     <module>company-api-dtos</module> 
    </modules> 

    <build> 
     <pluginManagement> 
      <plugins> 

       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>flatten-maven-plugin</artifactId> 
        <version>1.0.0</version> 
        <configuration> 
         <updatePomFile>true</updatePomFile> 
        </configuration> 
        <executions> 
         <execution> 
          <id>flatten</id> 
          <phase>process-resources</phase> 
          <goals> 
           <goal>flatten</goal> 
          </goals> 
         </execution> 
         <execution> 
          <id>flatten.clean</id> 
          <phase>clean</phase> 
          <goals> 
           <goal>clean</goal> 
          </goals> 
         </execution> 
        </executions> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>3.6.1</version> 
        <configuration> 
         <source>${maven.compiler.source}</source> 
         <target>${maven.compiler.target}</target> 
         <encoding>UTF-8</encoding> 
         <compilerArgument>-Xlint:all</compilerArgument> 
        </configuration> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-source-plugin</artifactId> 
        <version>3.0.1</version> 
        <executions> 
         <execution> 
          <id>bundle-sources</id> 
          <phase>package</phase> 
          <goals> 
           <!-- produce source artifact for main project sources --> 
           <goal>jar-no-fork</goal> 
          </goals> 
         </execution> 
        </executions> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-jar-plugin</artifactId> 
        <version>3.0.2</version> 
        <configuration> 
         <archive> 
          <manifest> 
           <addDefaultImplementationEntries>true</addDefaultImplementationEntries> 
          </manifest> 
         </archive> 
        </configuration> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-shade-plugin</artifactId> 
        <version>3.0.0</version> 
        <configuration> 
        <createDependencyReducedPom>true</createDependencyReducedPom> 
         <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.ServicesResourceTransformer" /> 
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
             <manifestEntries> 
              <Main-Class>com.companycyber.clientapi.ClientApiApplication</Main-Class> 
             </manifestEntries> 
            </transformer> 
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> 
             <resource>META-INF/spring.handlers</resource> 
            </transformer> 
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> 
             <resource>META-INF/spring.schemas</resource> 
            </transformer> 
           </transformers> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-javadoc-plugin</artifactId> 
        <version>2.10.4</version> 
        <executions> 
         <execution> 
          <id>attach-javadocs</id> 
          <goals> 
           <goal>jar</goal> 
          </goals> 
          <configuration> 
           <additionalparam>-Xdoclint:none</additionalparam> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 

       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>aspectj-maven-plugin</artifactId> 
        <version>1.10</version> 
        <executions> 
         <execution> 
          <id>compile</id> 
          <configuration> 
           <source>${maven.compiler.source}</source> 
           <target>${maven.compiler.target}</target> 
           <complianceLevel>${maven.compiler.target}</complianceLevel> 
           <verbose>false</verbose> 
           <outxml>true</outxml> 
           <aspectLibraries> 
            <aspectLibrary> 
            <groupId>org.springframework</groupId> 
             <artifactId>spring-aspects</artifactId> 
            </aspectLibrary> 
           </aspectLibraries> 
          </configuration> 
          <goals> 
           <goal>compile</goal> 
          </goals> 
         </execution> 
         <execution> 
          <id>test-compile</id> 
          <configuration> 
           <source>${maven.compiler.source}</source> 
           <target>${maven.compiler.target}</target> 
           <complianceLevel>${maven.compiler.target}</complianceLevel> 
           <verbose>false</verbose> 
           <aspectLibraries> 
            <aspectLibrary> 
             <groupId>org.springframework</groupId> 
             <artifactId>spring-aspects</artifactId> 
            </aspectLibrary> 
           </aspectLibraries> 
          </configuration> 
          <goals> 
           <goal>test-compile</goal> 
          </goals> 
         </execution> 
        </executions> 
        <dependencies> 
         <dependency> 
          <groupId>org.aspectj</groupId> 
          <artifactId>aspectjtools</artifactId> 
          <version>${aspectj.version}</version> 
         </dependency> 
        </dependencies> 
       </plugin> 

       <!-- FindBugs Static Analysis --> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>findbugs-maven-plugin</artifactId> 
        <version>3.0.4</version> 
        <configuration> 
         <effort>Max</effort> 
         <threshold>Low</threshold> 
         <failOnError>true</failOnError> 
         <includeFilterFile>${session.executionRootDirectory}/findbugs-security-include.xml</includeFilterFile> 
         <excludeFilterFile>${session.executionRootDirectory}/findbugs-security-exclude.xml</excludeFilterFile> 
         <plugins> 
          <plugin> 
           <groupId>com.h3xstream.findsecbugs</groupId> 
           <artifactId>findsecbugs-plugin</artifactId> 
           <version>1.6.0</version> 
          </plugin> 
         </plugins> 
        </configuration> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-antrun-plugin</artifactId> 
        <version>1.8</version> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-install-plugin</artifactId> 
        <version>2.5.2</version> 
       </plugin> 

      </plugins> 
     </pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>flatten-maven-plugin</artifactId> 
       <version>1.0.0</version> 
       <configuration> 
        <updatePomFile>true</updatePomFile> 
       </configuration> 
       <executions> 
        <execution> 
         <id>flatten</id> 
         <phase>process-resources</phase> 
         <goals> 
          <goal>flatten</goal> 
         </goals> 
        </execution> 
        <execution> 
         <id>flatten.clean</id> 
         <phase>clean</phase> 
         <goals> 
          <goal>clean</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

    <dependencyManagement> 
     <dependencies> 

      <!-- Jersey --> 
      <dependency> 
       <groupId>org.glassfish.jersey.core</groupId> 
       <artifactId>jersey-client</artifactId> 
       <version>${jersey.version}</version> 
       <exclusions> 
        <exclusion> 
         <groupId>org.glassfish.hk2.external</groupId> 
         <artifactId>aopalliance-repackaged</artifactId> 
        </exclusion> 
       </exclusions> 
      </dependency> 
      <dependency> 
       <groupId>org.glassfish.jersey.media</groupId> 
       <artifactId>jersey-media-json-jackson</artifactId> 
       <version>${jersey.version}</version> 
      </dependency> 

      <!-- Validation --> 
      <dependency> 
       <groupId>org.hibernate</groupId> 
       <artifactId>hibernate-validator</artifactId> 
       <version>${hibernate.validator.version}</version> 
      </dependency> 
      <dependency> 
       <groupId>javax.el</groupId> 
       <artifactId>javax.el-api</artifactId> 
       <version>${javax.el.version}</version> 
      </dependency> 
      <dependency> 
       <groupId>org.glassfish.web</groupId> 
       <artifactId>javax.el</artifactId> 
       <version>${javax.el.version}</version> 
      </dependency> 
      <dependency> 
       <groupId>commons-validator</groupId> 
       <artifactId>commons-validator</artifactId> 
       <version>${commons-validator.version}</version> 
      </dependency> 

      <!-- Enunciate --> 
      <dependency> 
       <groupId>com.webcohesion.enunciate</groupId> 
       <artifactId>enunciate-core-annotations</artifactId> 
       <version>${enunciate-plugin-version}</version> 
      </dependency> 

      <!-- Joda --> 
      <dependency> 
       <groupId>joda-time</groupId> 
       <artifactId>joda-time</artifactId> 
       <version>${joda.time.version}</version> 
      </dependency> 

      <!-- Apache Commons --> 
      <dependency> 
       <groupId>org.apache.commons</groupId> 
       <artifactId>commons-lang3</artifactId> 
       <version>${apache-commons-lang3-version}</version> 
      </dependency> 

      <!-- Unit testing --> 
      <dependency> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
       <version>${junit.version}</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.springframework</groupId> 
       <artifactId>spring-test</artifactId> 
       <version>${spring.version}</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.mockito</groupId> 
       <artifactId>mockito-core</artifactId> 
       <version>${mockito.version}</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.powermock</groupId> 
       <artifactId>powermock-module-junit4</artifactId> 
       <version>${powermock.version}</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.powermock</groupId> 
       <artifactId>powermock-api-mockito2</artifactId> 
       <version>${powermock.version}</version> 
       <scope>test</scope> 
      </dependency> 

      <dependency> 
       <groupId>com.amazonaws</groupId> 
       <artifactId>aws-java-sdk-bom</artifactId> 
       <version>${aws.java.sdk.bom.version}</version> 
       <type>pom</type> 
       <scope>import</scope> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 

    <repositories> 
     <repository> 
      <id>central</id> 
      <url>https://artifactory.company.loc/artifactory/libs-release/</url> 
     </repository> 
     <repository> 
      <id>snapshots</id> 
      <url>https://artifactory.company.loc/artifactory/libs-snapshot/</url> 
     </repository> 
     <repository> 
      <id>maven-central</id> 
      <url>https://repo.maven.apache.org/maven2/</url> 
     </repository> 
    </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <snapshots> 
       <enabled>false</enabled> 
      </snapshots> 
      <id>central</id> 
      <name>libs-release</name> 
      <url>https://artifactory.company.loc/artifactory/libs-release/</url> 
     </pluginRepository> 
     <pluginRepository> 
      <snapshots /> 
      <id>snapshots</id> 
      <name>libs-snapshot</name> 
      <url>https://artifactory.company.loc/artifactory/libs-snapshot</url> 
     </pluginRepository> 
    </pluginRepositories> 

    <distributionManagement> 
     <repository> 
      <id>central</id> 
      <name>artifactory.company.loc-releases</name> 
      <url>https://artifactory.company.loc/libs-release</url> 
     </repository> 
     <snapshotRepository> 
      <id>snapshots</id> 
      <name>artifactory.company.loc-snapshots</name> 
      <url>https://artifactory.company.loc/libs-snapshot</url> 
     </snapshotRepository> 
    </distributionManagement> 

    <scm> 
     <connection>scm:git:ssh://[email protected]/home/git/company.client-api.git</connection> 
     <developerConnection>scm:git:ssh://[email protected]/home/git/company.client-api.git</developerConnection> 
     <tag>HEAD</tag> 
    </scm> 

</project> 

DTOS(孩子)的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> 

    <parent> 
     <artifactId>company-api-parent-pom</artifactId> 
     <groupId>com.company</groupId> 
     <version>${revision}${changelist}</version> 
    </parent> 

    <artifactId>company-api-dtos</artifactId> 

    <dependencies> 
     <!-- Jersey --> 
     <dependency> 
      <groupId>org.glassfish.jersey.core</groupId> 
      <artifactId>jersey-client</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.glassfish.jersey.media</groupId> 
      <artifactId>jersey-media-json-jackson</artifactId> 
     </dependency> 

     <!-- Validation --> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-validator</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>javax.el</groupId> 
      <artifactId>javax.el-api</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.glassfish.web</groupId> 
      <artifactId>javax.el</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>commons-validator</groupId> 
      <artifactId>commons-validator</artifactId> 
     </dependency> 

     <!-- Enunciate --> 
     <dependency> 
      <groupId>com.webcohesion.enunciate</groupId> 
      <artifactId>enunciate-core-annotations</artifactId> 
     </dependency> 

     <!-- Apache Commons --> 
     <dependency> 
      <groupId>org.apache.commons</groupId> 
      <artifactId>commons-lang3</artifactId> 
      <version>${apache-commons-lang3-version}</version> 
     </dependency> 
     <dependency> 
      <groupId>joda-time</groupId> 
      <artifactId>joda-time</artifactId> 
     </dependency> 
     <!-- Unit testing --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.mockito</groupId> 
      <artifactId>mockito-core</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.powermock</groupId> 
      <artifactId>powermock-module-junit4</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.powermock</groupId> 
      <artifactId>powermock-api-mockito2</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>cz.jirutka.validator</groupId> 
      <artifactId>validator-collection</artifactId> 
      <version>2.2.0</version> 
     </dependency> 
    </dependencies> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-source-plugin</artifactId> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-javadoc-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 
</project> 
+0

您可以将异常堆栈跟踪添加到您的发布?你有没有尝试过设置Maven来生成详细的运行时输出?堆栈跟踪和详细输出应该精确定位Maven中问题的确切位置,提供足够的上下文详细信息以执行重点搜索任何可能导致或促成问题的已知错误,并允许进行完整的根本原因分析。 –

+0

请忽略我以前的评论。我只是对你的帖子做了详细的回顾,发现了你包含的Maven输出链接。我调整了链接,使其更易于查看,并希望能够更清晰地了解这些链接提供的信息 –

回答

1

原来,有一个解决ISS与Maven 3.5.0 UE在那里行家以前的版本下,POM内容被复制:

<project>...</project><project>...</project>

在一些下载的pom.xml文件

,但这并没有在以前的版本中出现问题了(出奇)。在Maven升级到3.5.0之后,那些损坏的pom.xml文件会导致此问题。

如果遇到此问题,只需删除.m2/repository下的文件,然后让Maven重新下载损坏的pom文件。

Maven bug [MNG-6216 | https://issues.apache.org/jira/browse/MNG-6216]原本有异常切换的前两个单词(即IndexArrayOutOfBounds),所以它从未出现在我的任何搜索中。我问他们是否被颠倒以符合实际的例外情况,并且他们遵守了。