我希望这不是重复,因为我肯定已经搜索过类似的question。我相信它可能是同样的症状,但却是一个非常不同的错误。
我正在尝试构建一个Android库项目,但将其作为.jar发布。 Jar提交的版本,将其发布到我们的内部Artifactory存储库。
我按照这个官方指南,但仍然遇到一个奇怪的“上下文URL不能为空”错误: Gradle+Artifactory+Plugin
我的 build.gradle :
buildscript {
/*
* For adding Gradle Artifactory Plugin
*/
repositories {
maven {
url 'https://artifactory.mydomain.net/artifactory/libs-release'
}
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.+'
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
version = "1.0.0"
group = 'com.myorg.network'
apply plugin: 'maven'
apply plugin: 'artifactory'
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName project.version
}
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
}
// https://stackoverflow.com/questions/19307341/android-library-gradle-release-jar
android.libraryVariants.all { variant ->
def name = variant.buildType.name
if (name.equals(com.android.builder.BuilderConstants.DEBUG)) {
return; // Skip debug builds.
}
def task = project.tasks.create "jar${name.capitalize()}", Jar
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
artifacts.add('archives', task);
}
repositories {
maven {
url 'https://artifactory.mydomain.net/artifactory/libs-release'
}
}
dependencies {
compile files('libs/volley.jar')
compile 'commons-lang:commons-lang:2.5'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.squareup:otto:1.3.4'
compile 'com.squareup:tape:1.2.0'
compile 'org.apache.commons:commons-compress:1.3'
compile 'org.slf4j:slf4j-api:1.7.5'
instrumentTestCompile 'org.mockito:mockito-all:1.9.5'
instrumentTestCompile 'com.google.dexmaker:dexmaker:1.0'
instrumentTestCompile('com.google.dexmaker:dexmaker-mockito:1.0') {
// Stuff breaks without this.
// See http://forums.gradle.org/gradle/topics/how_to_exclude_transitive_dependency
exclude group: 'org.hamcrest', module: 'hamcrest-core'
exclude group: 'org.objenesis', module: 'objenesis'
exclude group: 'org.mockito', module: 'mockito-core'
}
}
artifactory {
contextUrl = 'https://artifactory.mydomain.net/artifactory'
publish {
contextUrl = 'https://artifactory.mydomain.net/artifactory'
repository {
repoKey = 'libs-release-local'
username = 'xbeta'
password = 'password'
maven = true
}
}
resolve {
repository {
repoKey = 'libs-release'
}
}
}
构建失败:
$ ./gradlew --info clean artifactoryPublish
Starting Build
Settings evaluated using settings file '/Users/xbeta/workspace/rest-client/settings.gradle'.
Projects loaded. Root project using build file '/Users/xbeta/workspace/rest-client/build.gradle'.
Included projects: [root project 'rest-client', project ':rest-client']
Evaluating root project 'rest-client' using build file '/Users/xbeta/workspace/rest-client/build.gradle'.
Evaluating project ':rest-client' using build file '/Users/xbeta/workspace/rest-client/rest-client/build.gradle'.
Compiling build file '/Users/xbeta/workspace/rest-client/rest-client/build.gradle' using BuildScriptClasspathScriptTransformer.
Compiling build file '/Users/xbeta/workspace/rest-client/rest-client/build.gradle' using BuildScriptTransformer.
All projects evaluated.
FAILURE: Build failed with an exception.
* What went wrong:
Context URL cannot be empty
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
Total time: 13.165 secs
Stopped 0 Gradle compiler daemon(s).
已编辑使用--stacktrace:
运行* Exception is:
java.lang.IllegalStateException: Context URL cannot be empty
at org.jfrog.build.client.ArtifactoryClientConfiguration.getContextUrl(ArtifactoryClientConfiguration.java:130)
at org.jfrog.build.client.ArtifactoryClientConfiguration$ResolverHandler.getContextUrl(ArtifactoryClientConfiguration.java:223)
at org.jfrog.build.client.ArtifactoryClientConfiguration$RepositoryConfiguration.getUrl(ArtifactoryClientConfiguration.java:467)
at org.jfrog.build.client.ArtifactoryClientConfiguration$RepositoryConfiguration$getUrl.call(Unknown Source)
at org.jfrog.gradle.plugin.artifactory.ArtifactoryPluginBase$ProjectsEvaluatedBuildListener.defineResolvers(ArtifactoryPluginBase.groovy:77)
at org.jfrog.gradle.plugin.artifactory.ArtifactoryPluginBase$ProjectsEvaluatedBuildListener.this$3$defineResolvers(ArtifactoryPluginBase.groovy)
at org.jfrog.gradle.plugin.artifactory.ArtifactoryPluginBase$_ProjectsEvaluatedBuildListener_projectsEvaluated_closure1.doCall(ArtifactoryPluginBase.groovy:68)
at org.jfrog.gradle.plugin.artifactory.ArtifactoryPluginBase$ProjectsEvaluatedBuildListener.projectsEvaluated(ArtifactoryPluginBase.groovy:66)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy14.projectsEvaluated(Unknown Source)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy14.projectsEvaluated(Unknown Source)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:145)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:46)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:37)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
已编辑我发现这有效,但不确定为什么会有效,这是一个错误吗?为什么我需要在3个位置使用contextUrl
才能使其工作在指向相同网址的位置? contextUrl
块上的artifactory
设置应适用于publish
和resolve
块?:
artifactory {
contextUrl = 'https://artifactory.mydomain.net/artifactory'
publish {
contextUrl = 'https://artifactory.mydomain.net/artifactory'
repository {
repoKey = 'libs-release-local'
username = 'xbeta'
password = 'password'
maven = true
}
}
resolve {
contextUrl = 'https://artifactory.mydomain.net/artifactory'
repository {
repoKey = 'libs-release'
}
}
}