我被要求在几个项目中使用Gradle,并创建项目可能需要的各种jar文件的远程存储库。我对Gradle还不熟悉,但仅仅定义库依赖关系似乎并不困难。现在,关于存储库,我想使用Bitbucket作为Maven存储库的主机,遵循本指南maven-repo Wiki。由于我没有使用Maven的经验,而且我花了太多时间在这个指南上,有人能更详细地解释一下设置这个步骤的步骤吗?
谢谢。
发布于 2015-10-05 07:12:39
下面是我在bitbucket上创建Maven存储库所遵循的步骤:
maven-repo/wiki/Home指南I部分遵循。
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命令。
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。但不需要让它发挥作用。
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缓存的内容。
task showMeCache << {
configurations.compile.each { println it}
}https://stackoverflow.com/questions/32901651
复制相似问题