简体   繁体   English

如何在Maven 2中下载软件依赖项?

[英]How to download software dependencies in Maven 2?

I am very new in using Maven. 我是使用Maven的新手。 Appreciate if anyone can give me some helps. 感谢是否有人可以给我一些帮助。

I want to build a plugin for JIRA. 我想为JIRA构建一个插件。 I have installed Atlassian Plugin SDK which comes with Maven 2 (pre-bundled together). 我已经安装了Maven 2附带的Atlassian Plugin SDK(预先捆绑在一起)。

In my Java source codes, I want to import these packages from Atlassian repository: 在我的Java源代码中,我想从Atlassian存储库导入这些包:

import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.rpc.exception.*;
import com.atlassian.jira.rpc.auth.*;
import com.atlassian.jira.rpc.soap.beans.*;
import com.atlassian.jira.rpc.soap.service.*;
import com.atlassian.jira.rpc.soap.util.*;
import com.atlassian.jira.rpc.soap.JiraSoapServiceImpl;
import com.atlassian.jira.soap.axis.JiraSoapTokenResolver;
import org.apache.axis.encoding.Base64;

I have tried to use Maven to build another example plugin from Atlassian. 我曾尝试使用Maven从Atlassian构建另一个示例插件 I found that Maven is able to download all necessary dependencies packages from the repository and build the application without any problems. 我发现Maven能够从存储库下载所有必需的依赖包,并且没有任何问题地构建应用程序。

However, when I use Maven to build my own plugin, it failed to download the dependencies from Atlassian repository. 但是,当我使用Maven构建自己的插件时,无法从Atlassian存储库下载依赖项。 It shows the following error messages: 它显示以下错误消息:

...
xxxxx.java:[x,x] package com.atlassian.jira.rpc.exception does not exist
xxxxx.java:[x,x] package com.atlassian.jira.rpc.auth does not exist
xxxxx.java:[x,x] package com.atlassian.jira.rpc.soap.beans does not exist
xxxxx.java:[x,x] package com.atlassian.jira.rpc.soap.service does not exist
xxxxx.java:[x,x] package com.atlassian.jira.rpc.soap.util does not exist
xxxxx.java:[x,x] package com.atlassian.jira.rpc.soap does not exist
...

xxxxx.java:[x,x] cannot find symbol
symbol: class JiraSoapService
...

In my pom.xml , I have included these: 在我的pom.xml ,我包含了以下内容:

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>atlassian-jira</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>

In the Maven settings.xml file, I can see these repositories (default settings.xml in Maven 2 which is pre-bundled with Atlassian Plugin SDK installation): 在Maven settings.xml文件中,我可以看到这些存储库(Maven 2中的默认settings.xml,它与Atlassian Plugin SDK安装预先捆绑在一起):

<repositories>
<repository>
<id>atlassian-public</id>
<url>https://m2proxy.atlassian.com/repository/public</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
<repository>
<id>atlassian-plugin-sdk</id>
<url>file://${env.ATLAS_HOME}/repository</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>atlassian-public</id>
<url>https://m2proxy.atlassian.com/repository/public</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>

I have spent a long time to compare my pom.xml with other JIRA plugin's pom.xml . 我花了很长时间将我的pom.xml与其他JIRA插件的pom.xml进行比较。 But i still don't understand how to ask Maven to download JIRA packages from Atlassian repository. 但我仍然不明白如何让Maven从Atlassian存储库下载JIRA包。

Can anyone give me some helps? 谁能给我一些帮助? Thanks. 谢谢。

Your code is not compiling because the packages you are including are not contained in the atlassian-jira JAR. 您的代码未编译,因为您包含的包未包含在atlassian-jira JAR中。 It looks like you will need at least the following additional dependency: 看起来您至少需要以下附加依赖项:

<dependency>
  <groupId>atlassian-jira-rpc-plugin</groupId>
  <artifactId>atlassian-jira-rpc-plugin</artifactId>
</dependency>

But I could not find it in the JIRA repo. 但我在JIRA回购中找不到它。 You might have to Google to find out what repository its in (or install it manually, locally). 您可能需要Google查找其所在的存储库(或在本地手动安装)。

EDIT 编辑

To install a JAR into your repository you can use the following command: 要将JAR安装到存储库中,可以使用以下命令:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

检查提到的jira jar版本是否可用于远程存储库(https://m2proxy.atlassian.com/repository/public)?,如果不可用则更改版本,哪一个有完整的jar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM