从藏匿处迁移到bitbucket

时间:2018-01-23 16:10:48

标签: java maven plugins bitbucket pom.xml

Mi公司从stash迁移到bitbucket ,并且他们有一些 REST存储扩展插件 在bitbucket 中不再有效。插件由它们在内部开发并上载到附加组件部分(管理附加组件)。 我想知道是否有可能调整这些插件并让它们在bitbucket中工作或者我们必须重写代码。 根据本教程: https://confluence.atlassian.com/bitbucketserver/how-to-update-your-add-on-779302412.html  我所要做的就是将我们的包命名空间从com.atlassian.stash重命名为com.atlassian.bitbucket。我在 pom.xml文件和代码中也这样做但现在我有很多错误。 例如,在我更改代码中的导入之后,不再识别类CommitService: import com.atlassian.stash.commit.CommitService; 至 import com.atlassian.bitbucket.commit.CommitService; (现在这一行: private final CommitService commitService;
生成错误" 无法解析符号CommitService ")。 任何人都可以帮忙,因为我对插件开发没有多少经验。

http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.myCompany.bitbucket.plugins</groupId>
<artifactId>myCompany-rest-extensions</artifactId>
<version>1.2.2</version>

<organization>
    <name>MyCompany</name>
    <url>http://www.myCompany.com/</url>
</organization>

<name>myCompany-rest-extensions</name>
<description>This is the myCompany-rest-extensions plugin for Atlassian bitbucket.</description>
<packaging>atlassian-plugin</packaging>

<dependencies>
    <dependency>
        <groupId>com.atlassian.bitbucket</groupId>
        <artifactId>bitbucket-parent</artifactId>
        <version>${bitbucket.version}</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.sal</groupId>
        <artifactId>sal-api</artifactId>
        <version>${bitbucket.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.bitbucket</groupId>
        <artifactId>bitbucket-api</artifactId>
        <version>${bitbucket.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.bitbucket</groupId>
        <artifactId>bitbucket-spi</artifactId>
        <version>${bitbucket.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.bitbucket</groupId>
        <artifactId>bitbucket-page-objects</artifactId>
        <version>${bitbucket.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.bitbucket.server</groupId>
        <artifactId>bitbucket-api</artifactId>
        <version>${bitbucket.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>${bitbucket.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
        <scope>provided</scope>
    </dependency>

    <!-- WIRED TEST RUNNER DEPENDENCIES -->
    <dependency>
        <groupId>com.atlassian.plugins</groupId>
        <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
        <version>${plugin.testrunner.version}</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.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.2.7</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.2.2-atlassian-1</version>
    </dependency>
    <dependency>
        <groupId>com.atlassian.plugins.rest</groupId>
        <artifactId>atlassian-rest-common</artifactId>
        <version>1.0.2</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
           <!-- <artifactId>maven-bitbucket-plugin</artifactId>-->
            <artifactId>bitbucket-maven-plugin</artifactId>
            <version>${amps.version}</version>
            <extensions>true</extensions>
            <configuration>
                <products>
                    <product>
                        <id>bitbucket</id>
                        <instanceId>bitbucket</instanceId>
                        <version>${bitbucket.version}</version>
                        <dataVersion>${bitbucket.data.version}</dataVersion>
                    </product>
                </products>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<properties>
    <bitbucket.version>${bitbucket.version}</bitbucket.version>
    <bitbucket.data.version>${bitbucket.version}</bitbucket.data.version>
    <amps.version>5.0.13</amps.version>
    <plugin.testrunner.version>1.2.3</plugin.testrunner.version>
</properties>

import com.atlassian.bitbucket.commit.CommitService;
// other imports

@Path("/stash-projects")
public class ProjectsListRestResource{
    private final CommitService commitService;
    // other declarations

    public ProjectsListRestResource( RefService refService, CommitService commitService , ......){
        this.commitService = commitService;
        // other initializations
    }

    @GET
    @AnonymousAllowed
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response getMessage()
    {
        log.info("Rest plugin main function start");
        List<ProjectRestResourceModel> projects = new ArrayList<ProjectRestResourceModel>();
        PageRequest repoPageReq = new PageRequestImpl(0,100);
        for(String projectkey : projectService.findAllKeys())
        {
            Project project = projectService.getByKey(projectkey);
            ProjectRestResourceModel projectRestResourceModel = new ProjectRestResourceModel();
            projectRestResourceModel.setKey(projectkey);
            // ..............

            Page<? extends Repository> repoPage = repositoryService.findByProjectKey(projectkey, repoPageReq);
            Set<HashMap<String,String>> repoList=new HashSet<HashMap<String, String>>();

            for (Repository r : repoPage.getValues()) {
                HashMap<String, String> repo = new HashMap<String, String>();
                repo.put("repoName", r.getName());
               // .....
                if(mirrorHook!=null && mirrorHook.isEnabled()) {
                    //....
                }
            repoList.add(repo);
            }

            projectRestResourceModel.setRepoList(repoList);

            Map<Permission,Set<String>> groupMap=new HashMap<Permission,Set<String>>();
           //....
            groupMap.put(Permission.PROJECT_ADMIN, new HashSet<String>());
            for (  PermittedGroup pg : permittedGroupProjectPage.getValues()) {
                //...
            }
            projectRestResourceModel.setAdminGroups(groupMap.get(Permission.PROJECT_ADMIN));
            userMap.put(Permission.PROJECT_ADMIN, new HashSet<String>());
            for (  PermittedUser pu : permittedUserProjectPage.getValues()) {
                //...
            }
            projectRestResourceModel.setAdminUsers(userMap.get(Permission.PROJECT_ADMIN));
            projects.add(projectRestResourceModel);
        }
        return Response.ok(projects, MediaType.APPLICATION_JSON_TYPE).build();
    }
}

0 个答案:

没有答案