插件版本解析两次,第二次错误版本已解决

时间:2016-07-28 16:49:47

标签: java maven maven-plugin maven-plugin-development

我正在尝试从源

构建JIRA 6.0.7

https://confluence.atlassian.com/jira064/building-jira-from-source-720411927.html

它与JDK-8构建了问题,所以我不得不使用JDK-7。一个工件下载最新的插件版本(虽然在pom.xml中定义了显式版本)并且由于类文件版本而失败。

以下是mvn -X package的输出:

[INFO] Scanning for projects...
[DEBUG] com.atlassian.maven.plugins:maven-jira-plugin:jar:4.1.5:
[DEBUG]    com.atlassian.maven.archetypes:jira-plugin-archetype:jar:4.1.5:runtime
[DEBUG]    com.atlassian.maven.plugins:maven-amps-plugin:jar:4.1.5:compile
...
[DEBUG]   Included: com.atlassian.maven.plugins:maven-amps-plugin:jar:4.1.5
...
[DEBUG] Resolving plugin version for com.atlassian.maven.plugins:maven-amps-plugin
[DEBUG] Could not find metadata com.atlassian.maven.plugins:maven-amps-plugin/maven-metadata.xml in local (C:\m2repo)
[DEBUG] Skipped remote update check for com.atlassian.maven.plugins:maven-amps-plugin/maven-metadata.xml, locally cached metadata up-to-date.
[DEBUG] Skipped remote update check for com.atlassian.maven.plugins:maven-amps-plugin/maven-metadata.xml, locally cached metadata up-to-date.
[DEBUG] Resolved plugin version for com.atlassian.maven.plugins:maven-amps-plugin to 6.2.6 from repository atlassian-proxy (https://m2proxy.atlassian.com/repository/public, releases+snapshots)
...
Caused by: java.lang.UnsupportedClassVersionError: com/atlassian/maven/plugins/amps/osgi/ValidateTestManifestMojo : Unsupported major.minor version 52.0

这是重现问题的简化pom:

<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

    <groupId>bar</groupId>
    <artifactId>foo</artifactId>
    <version>1.1.7</version>
    <packaging>atlassian-plugin</packaging>
    <name>foo</name>
    <description>foo</description>


<dependencies>
</dependencies>

    <repositories>
        <repository>
            <id>atlassian-proxy</id>
            <name>Atlassian Maven 2 Proxy</name>
            <url>https://m2proxy.atlassian.com/repository/public</url>
        </repository>
        <repository>
            <id>atlassian-contrib</id>
            <name>Atlassian Contrib Repository</name>
            <url>https://m2proxy.atlassian.com/contrib</url>
        </repository>
    </repositories>
    <pluginRepositories>
    <pluginRepository>
            <id>atlassian-proxy</id>
            <name>Atlassian Maven 2 Proxy</name>
            <url>https://m2proxy.atlassian.com/repository/public</url>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-jira-plugin</artifactId>
                <version>4.1.5</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>

</project>

注意

maven-amps-plugin-4.1.5.jar是为java 6构建的:

C:\>javap -v -classpath maven-amps-plugin-4.1.5.jar com.atlassian.maven.plugins.amps.osgi.ValidateTestManifestMojo | find "major version"
  major version: 50

注2

我非常绝望,我现在正在调试maven代码。 https://maven.apache.org/ref/3.3.1/xref/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.html#L90

在回到resolveFromRepository()之前,它会尝试resolveFromProject(),但会失败,因为request.pom == null。为什么呢?

project.getBuildPlugins()使用maven-amps-plugin返回(在众多中)version == null。为什么呢?

project.getBuildPlugins().get(0)
    artifactId  "maven-jira-plugin" (id=489)    
    version "4.1.5" (id=498)    

project.getBuildPlugins().get(5)
    artifactId  "maven-amps-plugin" (id=402)    
    version null    

最初,在解析Plugin时使用正确的版本创建com/atlassian/amps/standalone/4.1.5/standalone-4.1.5.pom对象,但在DefaultLifecyclePluginAnalyzer.parseLifecyclePhaseDefinitions()中创建另一个实例。我想这是由<packaging>atlassian-plugin</packaging>

引起的

1 个答案:

答案 0 :(得分:0)

似乎maven-amps-plugin 4.1.5,maven-jira-plugin的依赖关系是使用JDK 8构建的。我试图尝试我可以获得的版本,希望是以前的版本。奇怪的是,Maven Central从2015年开始有5.0.18,所以我对它感到厌烦,最终出现了Oracle驱动程序的问题,这是好的(因为Oracle驱动程序,如果我没有记错的话,不会存储在Central上)。您的本地存储库可能拥有它,此代码段可以帮助您。因此,即使不太可能正确解决您的问题,以防万一。

        <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>maven-jira-plugin</artifactId>
            <version>4.1.5</version>
            <extensions>true</extensions>
            <dependencies>
                <dependency>
                    <groupId>com.atlassian.maven.plugins</groupId>
                    <artifactId>maven-amps-plugin</artifactId>
                    <version>5.0.18</version>
                </dependency>
            </dependencies>
        </plugin>