首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BitBucket maven存储库

BitBucket maven存储库
EN

Stack Overflow用户
提问于 2015-10-02 06:31:08
回答 1查看 1.8K关注 0票数 0

我被要求在几个项目中使用Gradle,并创建项目可能需要的各种jar文件的远程存储库。我对Gradle还不熟悉,但仅仅定义库依赖关系似乎并不困难。现在,关于存储库,我想使用Bitbucket作为Maven存储库的主机,遵循本指南maven-repo Wiki。由于我没有使用Maven的经验,而且我花了太多时间在这个指南上,有人能更详细地解释一下设置这个步骤的步骤吗?

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-05 07:12:39

下面是我在bitbucket上创建Maven存储库所遵循的步骤:

maven-repo/wiki/Home指南I部分遵循。

  1. 所有这些工作所需的任何本地配置。 安装maven。https://www.youtube.com/watch?v=Jtj-0yhox5s 可选:安装python。
  2. 将BitBucket中的存储库设置为Maven存储库
代码语言:javascript
复制
1. Create a local folder e.g maven-repo with sub folders maven-repo\jars and maven-repo\repository
2. Copy the jar files into maven-repo\jars.
3. In order to install one of the jars into the repository use the maven command:

mvn install:install-file -DgroupId={jarOwner..more like group folder} -DartifactId={jarName} -Dversion={x.x.x} -Dfile={Path to the jar file in maven-repo\jars} -Dpackaging=jar -DgeneratePom=true -DlocalRepositoryPath=./repository -DcreateChecksum=true

例如mvn install:install-file -DgroupId=com.mycompany -DartifactId=GSON-2.2.4 -Dversion=2.2.4 -Dfile=C:\Development\maven-repo\jars\gson-2.2.4.jar -Dpackaging=jar -DgeneratePom=true -DlocalRepositoryPath=./repository -DcreateChecksum=true

可选的,如果有很多jars,您可以使用installJars.py脚本(这个脚本的所有者是我遵循的指南的创建者)。在cmd:python.exe installJars {jarsFolder_FullPath} {version}中,但是所有库安装都将具有相同的version..so,可以将其视为存储库版本,并将jar版本包含在jar名称(ArtifactId)中。该脚本还为所有库的安装生成一个依赖文件和maven命令。

代码语言:javascript
复制
1. Create a bitbucket PUBLIC repository with the same name as the local (maven-repo). Open the bitbucket project in SourceTree, then copy the content of the maven-repo of step 1 into the maven-repo folder which is linked with bitbucket. Commit and push. The path for each jar in bitbucket should be maven-repo/repository/{groupId}/{artifactId}/{version}/{artifactId+version}.jar                                          e.g maven-repo/repository/com/mycompany/gson-2.2.4/1.0/gson-2.2.4-1.0.jar

指南中还有一个步骤(@document)创建一个主依赖jar。但不需要让它发挥作用。

  1. 设置一个IntelliJ项目以引用存储库中的库,以便进行一致的构建 要启动使用gradle的新IntelliJ项目,请单击“文件->新项目”,从列表中选择Gradle。检查“自动为空内容根创建目录”,并确保选择了“用户默认gradle包装器”。单击next。说出项目的名称。点击finish。 在根目录下有build.gradle文件。为了使用自定义存储库,从存储库中删除mavenCentral()并添加:

repositories { maven { url 'https://bitbucket.org/{bitbucketUsername}/maven-repo/raw/master/repository/

} }

然后在同一个文件中定义库依赖项,如下所示:

dependencies{ compile 'com.mycompany:gson-2.2.4:1.0'

//compile '{groupId}:{artifactId}:{version}' <--all these as defined in the installation maven commands. compile 'com.mycompany:license4j-1.6:1.0' compile 'com.mycompany:kendo-taglib-2015.1.429:1.0' }

建造这个项目。如果库没有出现,请单击Gradle任务(从左侧列表),然后单击刷新按钮。

您可以在build.gradle中添加以下行,以便打印gradle缓存的内容。

代码语言:javascript
复制
task showMeCache << {
  configurations.compile.each { println it}
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32901651

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档