2017-06-23 58 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),所以它從未出現在我的任何搜索中。我問他們是否被顛倒以符合實際的例外情況,並且他們遵守了。