本文介绍了ArtiFactory+自定义Gradle插件以编程方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个自定义插件,以消除以下方面的需要:
artifactory {
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
contextUrl = "${artifactory_contextUrl}"
repoKey = 'android-dev'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
resolve {
repository {
contextUrl = "${artifactory_contextUrl}"
repoKey = 'android-dev-distributions'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
以下是我如何以编程方式完成此操作:
DefaultExtraPropertiesExtension ext = (((DefaultExtraPropertiesExtension) project.property("ext")));
ext.setProperty("artifactory", new ArtifactoryDsl(contextUrl, publish, resolve));
这应该会起作用,对吗?ArtifactoryDsl对象具有所有正确的字段(ConextUrl、Publish、Resolve及其各自的内部字段)。
这是错误:
14:46:49.752 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.IllegalStateException: Context URL cannot be empty
14:46:49.753 [ERROR] [org.gradle.BuildExceptionReporter] at org.jfrog.build.client.ArtifactoryClientConfiguration.getContextUrl(ArtifactoryClientConfiguration.java:111)
14:46:49.754 [ERROR] [org.gradle.BuildExceptionReporter] at org.jfrog.build.client.ArtifactoryClientConfiguration$PublisherHandler.getContextUrl(ArtifactoryClientConfiguration.java:225)
14:46:49.754 [ERROR] [org.gradle.BuildExceptionReporter] at org.jfrog.gradle.plugin.artifactory.extractor.BuildInfoTask.prepareAndDeploy(BuildInfoTask.java:526)
14:46:49.755 [ERROR] [org.gradle.BuildExceptionReporter] at org.jfrog.gradle.plugin.artifactory.extractor.BuildInfoTask.collectProjectBuildInfo(BuildInfoTask.java:440)
14:46:49.755 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
14:46:49.755 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
14:46:49.756 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
14:46:49.756 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
14:46:49.757 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:533)
14:46:49.757 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
14:46:49.758 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
14:46:49.777 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
14:46:49.778 [ERROR] [org.gradle.BuildExceptionReporter] ... 66 more
推荐答案
不,这行不通。您的插件必须应用ArtiFactory插件,然后使用project.artifactory
(Groovy)或project.getExtensions().getByName("artifactory")
(Java)获取artifactory
对象,然后配置该对象。
这篇关于ArtiFactory+自定义Gradle插件以编程方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!