gpt4 book ai didi

gradle - 使用生成的gradle.properties时,Gradle Artifactory部署失败

转载 作者:行者123 更新时间:2023-12-03 03:57:23 26 4
gpt4 key购买 nike

我有以下build.gradle文件:

plugins {
id 'java-gradle-plugin'
id 'com.gradle.plugin-publish' version '0.10.1'
id 'groovy'
id 'maven-publish'
id "com.jfrog.artifactory" version "4.9.1"
}

group = 'de.gafertp'
version = '2.0.0'

repositories {
mavenCentral()
}

dependencies {
compile 'net.sourceforge.plantuml:plantuml:1.2019.1'

testCompile 'org.junit.jupiter:junit-jupiter-api:5.4.0'
testCompile 'org.junit-pioneer:junit-pioneer:0.3.0'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.4.0'
}

gradlePlugin {
plugins {
plantUmlPlugin {
id = 'de.gafertp.plantuml'
displayName = 'Gradle PlantUML Plugin'
description = 'A very simple plugin to render PlantUML files. ' +
'Takes a set of diagram files together with desired output files / formats ' +
'and renders them with PlantUML (http://plantuml.com/).'
implementationClass = 'de.gafertp.PlantUmlPlugin'
}
}
}

pluginBundle {
website = 'https://github.com/codecholeric/gradle-plantuml-plugin'
vcsUrl = 'https://github.com/codecholeric/gradle-plantuml-plugin'
tags = ['plantuml']
}

publishing {
publications {
plantUmlPluginJar(MavenPublication) {
from components.java
}
}
}

artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'gradle-dev-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
println "username=${artifactory_user}"
println "password=${artifactory_password}"
maven = true
}
defaults {
publications('plantUmlPluginJar')
}
}
resolve {
repository {
repoKey = 'gradle-dev'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}

test {
useJUnitPlatform()
}

而这个gradle.properties文件:
artifactory_user=${security.getCurrentUsername()}
artifactory_password=${security.getEncryptedPassword()!"blahblah"}
artifactory_contextUrl=http://localhost:8081/artifactory

构建失败,并出现以下错误:
Execution failed for task ':artifactoryDeploy'.
> java.io.IOException: Failed to deploy file. Status code: 401 Response message: Artifactory returned the following errors:
Unauthorized Status code: 401

如果我们查看打印的用户名和密码,我们将看到:
username=${security.getCurrentUsername()}
password=${security.getEncryptedPassword()!"blahblah"}

Gradle将属性值视为文字字符串,而不是对其求值。所以问题似乎是找不到 security对象,因为如果我直接用其值替换 build.gradle文件中的属性,则会发生以下错误:
A problem occurred evaluating root project 'gradle-plantuml-plugin'.
> Could not get unknown property 'security' for object of type org.jfrog.gradle.plugin.artifactory.dsl.DoubleDelegateWrapper.

我究竟做错了什么?使用纯文本用户名和密码时,部署工作正常,但我想使用自动生成的登录方式(使用加密密码)。

最佳答案

看来gradle.properties应该看起来像这样:

username=your_username
password=blahblah

我们假设 blahblah是您的加密密码。

关于gradle - 使用生成的gradle.properties时,Gradle Artifactory部署失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54771758/

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