首页 > 解决方案 > Atlassian bitbucket插件maven编译错误

问题描述

我有与 BitBucket 版本 5.2.2 一起使用的插件,我想更新它以支持 BitBucket 版本6.8.0。在我尝试运行时更新pom.xml如下后,mvn compile我面临依赖错误:

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

        <modelVersion>4.0.0</modelVersion>
        <groupId>*******custom-plugin-groupId*******</groupId>
        <artifactId>*******custom-plugin-artifactId*******</artifactId>
        <version>2.0.0</version>

        <parent>
            <groupId>*******custom-parent-plugin-groupId*******</groupId>
            <artifactId>parent</artifactId>
            <version>0.7</version>
        </parent>

        <name>*******Plugin Name*******</name>
        <description>*******Plugin Description*******</description>
        <packaging>atlassian-plugin</packaging>

        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>com.atlassian.bitbucket.server</groupId>
                    <artifactId>bitbucket-parent</artifactId>
                    <version>${bitbucket.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>

        <dependencies>
            <dependency>
                <groupId>com.atlassian.sal</groupId>
                <artifactId>sal-api</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.atlassian.bitbucket.server</groupId>
                <artifactId>bitbucket-api</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.atlassian.bitbucket.server</groupId>
                <artifactId>bitbucket-spi</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.atlassian.bitbucket.server</groupId>
                <artifactId>bitbucket-page-objects</artifactId>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>4.5.1</version>
                <classifier>tests</classifier>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-annotation</artifactId>
                <scope>compile</scope>
            </dependency>

            <dependency>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-runtime</artifactId>
                <scope>runtime</scope>
            </dependency>

            <dependency>
                <groupId>javax.inject</groupId>
                <artifactId>javax.inject</artifactId>
                <version>1</version>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>com.atlassian.plugins</groupId>
                <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
                <version>${plugin.testrunner.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <version>1.5.7.RELEASE</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>2.12.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>javax.ws.rs</groupId>
                <artifactId>jsr311-api</artifactId>
                <version>1.1.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
            </dependency>
            <dependency>
                <groupId>com.atlassian.templaterenderer</groupId>
                <artifactId>atlassian-template-renderer-api</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>4.2.5.RELEASE</version>
            </dependency>
        </dependencies>

        <build>
            <plugins>
                <plugin>
                    <groupId>com.atlassian.maven.plugins</groupId>
                    <artifactId>bitbucket-maven-plugin</artifactId>
                    <version>${amps.version}</version>
                    <extensions>true</extensions>
                    <configuration>
                        <extractDependencies>false</extractDependencies>
                        <products>
                            <product>
                                <id>bitbucket</id>
                                <instanceId>bitbucket</instanceId>
                                <version>${bitbucket.version}</version>
                                <dataVersion>${bitbucket.data.version}</dataVersion>
                            </product>
                        </products>
                        <instructions>
                            <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>

                            <Import-Package>
                                org.springframework.osgi.*;resolution:="optional",
                                org.eclipse.gemini.blueprint.*;resolution:="optional",
                                *
                            </Import-Package>

                            <Spring-Context>*</Spring-Context>
                        </instructions>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>com.atlassian.plugin</groupId>
                    <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                    <version>${atlassian.spring.scanner.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>atlassian-spring-scanner</goal>
                            </goals>
                            <phase>process-classes</phase>
                        </execution>
                    </executions>
                    <configuration>
                        <includeExclude>-com.atlassian.plugin.spring.scanner.annotation.*</includeExclude>

                        <scannedDependencies>
                            <dependency>
                                <groupId>com.atlassian.plugin</groupId>
                                <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                            </dependency>
                        </scannedDependencies>
                        <verbose>false</verbose>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.6.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.eclipse.m2e</groupId>
                        <artifactId>lifecycle-mapping</artifactId>
                        <version>1.0.0</version>
                        <configuration>
                            <lifecycleMappingMetadata>
                                <pluginExecutions>
                                    <pluginExecution>
                                        <pluginExecutionFilter>
                                            <groupId>
                                                com.atlassian.maven.plugins
                                            </groupId>
                                            <artifactId>
                                                bitbucket-maven-plugin
                                            </artifactId>
                                            <versionRange>
                                                [6.3.21,)
                                            </versionRange>
                                            <goals>
                                                <goal>
                                                    generate-rest-docs
                                                </goal>
                                            </goals>
                                        </pluginExecutionFilter>
                                        <action>
                                            <ignore></ignore>
                                        </action>
                                    </pluginExecution>
                                </pluginExecutions>
                            </lifecycleMappingMetadata>
                        </configuration>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
       <properties>
            <bitbucket.version>6.8.0</bitbucket.version>
            <bitbucket.data.version>6.8.0</bitbucket.data.version>
            <amps.version>6.2.11</amps.version>
            <plugin.testrunner.version>1.2.3</plugin.testrunner.version>
            <atlassian.spring.scanner.version>1.2.13 
            </atlassian.spring.scanner.version>
            <atlassian.plugin.key>${project.groupId}.${project.artifactId} 
            </atlassian.plugin.key>
        </properties>
    </project>

编译错误:

[INFO] --- bitbucket-maven-plugin:6.2.11:compress-resources (default-compress-resources) @ custom-plugin ---
    [WARNING] Error injecting: com.atlassian.maven.plugins.updater.MarketplaceSdkResource
java.lang.NoClassDefFoundError: Lorg/codehaus/jackson/map/ObjectMapper;
    at java.lang.Class.getDeclaredFields0 (Native Method)
    at java.lang.Class.privateGetDeclaredFields (Class.java:2583)
    at java.lang.Class.getDeclaredFields (Class.java:1916)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.map.ObjectMapper

我不确定对于提到的 bitbucket 版本,ampsbitbucket-maven-plugin的对应版本应该是什么,这可能是错误的原因之一。

标签: mavenbitbucketatlassian-plugin-sdk

解决方案


您使用的是不兼容的放大器版本。使用 BB 6.8.0,您需要安培 8.0.16 https://marketplace.atlassian.com/apps/1210993/atlassian-plugin-sdk-tgz/version-history


推荐阅读