kev*_*nmm 3 artifactory gradle gradlew
所以,我在试图让 build-info-extractor-gradle 插件工作时我的智慧结束了......抱歉发泄。;-)
我正在使用 gradle 包装器,指定 gradle 1.6,artifactory 3.0.0,并尝试指定对 build-info-extractor-gradle 插件 2.1.x-SNAPSHOT 的依赖,因为这是gradle 1.5 及更高版本的指定版本.
我试图按照本教程视频进行操作,但它肯定已经过时了,因为它仍在引用 gradle 1.0 并指定 jfrog 存储库路径,其中不包含 2.x 版本的插件。
settings.gradle(从 artifactory 生成)
buildscript {
repositories {
maven {
url 'http://artifactory.build.somewhere.com:8081/artifactory/gradle'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.1.x-SNAPSHOT'
}
}
allprojects {
apply plugin: 'artifactory'
}
artifactory {
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = 'gradle-release-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
ivy {
ivyLayout = '[organization]/[module]/ivy-[revision].xml'
artifactLayout = '[organization]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]'
mavenCompatible = false
}
}
}
resolve {
repository {
repoKey = 'gradle'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我在本地上传 jar,我的存储库配置确实有效,例如,这就是我下载 build-info-extractor-gradle jar 的方式。但是,所有依赖项都失败了,如您所见:
$ gradlew tasks
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration 'classpath'.
> Could not find commons-io:commons-io:2.0.1.
Required by:
unspecified:unspecified:unspecified > org.jfrog.buildinfo:build-info-extractor-gradle:2.1.x-SNAPSHOT
> Could not find org.apache.ivy:ivy:2.2.0.
Required by:
unspecified:unspecified:unspecified > org.jfrog.buildinfo:build-info-extractor-
...
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Run Code Online (Sandbox Code Playgroud)
关于我的 gradle 配置或我的 artifactory repo 配置有什么问题的任何想法?为什么它不能解析来自远程存储库的外部依赖项?我应该只添加 mavenCentral 吗?
我将 mavenCentral() 添加到存储库中,只是为了看看会发生什么并得到:
$ gradlew tasks
Download http://repo1.maven.org/maven2/commons-io/commons-io/2.0.1/commons-io-2.0.1.pom
Download http://repo1.maven.org/maven2/org/apache/commons/commons-parent/15/commons-parent-15.pom
Download http://repo1.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.pom
Download http://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom
Download http://repo1.maven.org/maven2/org/apache/commons/commons-parent/5/commons-parent-5.pom
Download http://repo1.maven.org/maven2/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.pom
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration 'classpath'.
> Could not find org.jfrog.buildinfo:build-info-extractor:2.1.x-SNAPSHOT.
Required by:
unspecified:unspecified:unspecified > org.jfrog.buildinfo:build-info-extractor-gradle:2.1.x-SNAPSHOT
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Run Code Online (Sandbox Code Playgroud)
开始新鲜。删除了 mavenCentral() 和本地上传的 jar 和 pom,然后使用 --info 和 --refresh-dependencies 运行:
$ gradlew --refresh-dependencies -i tasks
Starting Build
Settings evaluated using empty settings script.
Projects loaded. Root project using build file 'D:\repos\some_build\build.gradle'.
Included projects: [root project 'some_build']
Evaluating root project 'some_build' using build file 'D:\repos\some_build\build.gradle'.
Compiling build file 'D:\repos\some_build\build.gradle' using BuildScriptClasspathScriptTransformer.
Resource missing. [HTTP GET: http://artifactory.build.somewhere.com:8081/artifactory/gradle/org/jfrog/buildinfo/build-info-extractor-gradle/2.1.0/build-info-extractor-gradle-2.1.0.pom]
Resource missing. [HTTP HEAD: http://artifactory.build.somewhere.com:8081/artifactory/gradle/org/jfrog/buildinfo/build-info-extractor-gradle/2.1.0/build-info-extractor-gradle-2.1.0.jar]
FAILURE: Build failed with an exception.
Run Code Online (Sandbox Code Playgroud)
所以,很明显,我的虚拟“gradle”存储库没有找到工件。如何判断它是否正在搜索远程“gradle-plugins”存储库?
哦!事实证明,有两个非常重要的配置选项,禁用远程存储库解析,默认情况下是选中的(我不记得选中/取消选中这些?)。
无论如何,这就是我所做的,为了最终让gradle-artifactory 插件工作,通过我的虚拟仓库的解析:
Admin -> Configuration -> General
General Settings
Admin -> Configuration -> Repositories -> {Edit the virtual repo} -> Advanced Settings
gradle-plugins
远程仓库添加到您的虚拟仓库
New
在远程存储库中选择jfrog-gradle-plugins
URL
为http://repo.jfrog.org/artifactory/gradle-pluginsjfrog-gradle-plugins
远程仓库添加到您的虚拟仓库Selected Repositories
Edit
将以下内容添加到build.gradle
:
buildscript {
repositories {
maven {
url "${repositoryUrl}/libs-release"
}
}
dependencies {
classpath( group: 'org.jfrog.buildinfo',
name: 'build-info-extractor-gradle',
version: '2.2.2')
}
}
Run Code Online (Sandbox Code Playgroud)
将以下内容添加到gradle.properties
:
repositoryUrl = http://my.artifactory.server:8081/artifactory
repositoryUser = me
repositoryPassword = thisIsAPasswordStoredInMyUserDirectory
Run Code Online (Sandbox Code Playgroud)
希望能帮助那些在开始集成Artifactory和Gradle 方面苦苦挣扎的人。
使用跟踪REST API 选项。例如:
归档时间: |
|
查看次数: |
12569 次 |
最近记录: |