所以,我最终试图让build-info-extractor-gradle插件工作......对不起发泄 . ;-)
我正在使用gradle包装器,指定gradle 1.6,artifactory 3.0.0,并尝试指定build-info-extractor-gradle插件2.1.x-SNAPSHOT的依赖关系,因为这是gradle 1.5及更高版本的specified version .
我试图遵循这个tutorial video,但它必须过时,因为它仍然引用gradle 1.0并指定jfrog repo路径,它不包含2.x版本的插件 .
Artifactory设置
-
local repo - "gradle-release-local" - 布局设置为gradle-default
-
remote repo - "gradle-plugins" - 从jfrog导入稍加修改 - 例如http://repo.jfrog.org/artifactory/gradle-plugins-snapshots
-
虚拟仓库 - "gradle" - "gradle-release-local"和"gradle-plugins"
Gradle设置
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
}
}
}
如果我在本地上传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
关于我的gradle配置或神器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
更新#2
开始新鲜 . 删除了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.
所以,很明显,我的虚拟“gradle”回购并没有找到工件 . 如何判断它是否正在搜索远程“gradle-plugins”仓库?
2 回答
卫生署!事实证明,有两个非常重要的配置选项,即默认选择的远程存储库解析(我不记得检查/取消选中这些?) .
无论如何,这是我做的,为了最终得到gradle-artifactory plugin工作,通过我的虚拟仓库解决:
禁用全局脱机模式
转到:
Admin -> Configuration -> General
确保取消选择 Global Offline Mode . 你会在
General Settings
看到这个选项保存
为虚拟仓库启用远程工件解析
转到:
Admin -> Configuration -> Repositories -> {Edit the virtual repo} -> Advanced Settings
确保虚拟存储库已选中 Artifactory Requests Can Retrieve Remote Artifacts
保存
将
gradle-plugins
远程仓库添加到虚拟仓库在远程存储库中选择
New
为远程仓库指定名称,例如
jfrog-gradle-plugins
设置
URL
至http://repo.jfrog.org/artifactory/gradle-plugins保存
使用
Edit
选项将jfrog-gradle-plugins
远程仓库添加到虚拟仓库的Selected Repositories
保存
将以下内容添加到
build.gradle
:将以下内容添加到
gradle.properties
:希望能帮助任何人开始积累Artifactory和Gradle .
有关在Artifactory中调试工件分辨率的提示
使用trace REST API选项 . 例如:
http://repo.jfrog.org/artifactory/gradle-plugins/org/jfrog/buildinfo/build-info-extractor-gradle/2.2.2/build-info-extractor-gradle-2.2.2?trace
看起来文档有误导性:(对不起 . 我现在正在添加澄清说明 .
您正在查看的页面是一个全新(不同且更好)
artifactory-publish
插件的文档,但在代码中您使用的是经典的artifactory
插件(也没关系) .请查看this page以获取
artifactory
插件的文档 .附:你非常欢迎尝试使用
artifactory-publish
插件,这太棒了 .