gpt4 book ai didi

groovy - Artifactory + Custom Gradle插件编程

转载 作者:行者123 更新时间:2023-12-03 03:37:59 25 4
gpt4 key购买 nike

我正在编写一个自定义插件,以消除以下需求:

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 对象具有所有正确的字段(contextUrl,发布,使用它们各自的内部字段解析)。

这是错误:
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插件,然后使用artifactory(Groovy)或project.artifactory(Java)获取project.getExtensions().getByName("artifactory")对象,然后配置该对象。

关于groovy - Artifactory + Custom Gradle插件编程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25556305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com