Java buildscript中的gradle.properties值
我试图在Java项目的Gradle构建脚本中包含类路径依赖项。我有Java buildscript中的gradle.properties值,java,gradle,build.gradle,Java,Gradle,Build.gradle,我试图在Java项目的Gradle构建脚本中包含类路径依赖项。我有gradle.properties文件,其中列出了两个变量:nexusUsername和nexusPassword。这两种方法在项目根存储库中的使用方式与下面buildscript存储库中的使用方式相同,并且工作正常-加载依赖项 但是,在如下配置buildscript时: buildscript { repositories { maven { credentials {
gradle.properties
文件,其中列出了两个变量:nexusUsername
和nexusPassword
。这两种方法在项目根存储库中的使用方式与下面buildscript存储库中的使用方式相同,并且工作正常-加载依赖项
但是,在如下配置buildscript时:
buildscript {
repositories {
maven {
credentials {
username nexusUsername
password nexusPassword
}
url 'https://edited'
}
}
dependencies {
classpath 'edited'
}
}
Could not GET 'https://edited.pom'. Received status code 403 from server: Forbidden
我得到一个类似这样的错误:
buildscript {
repositories {
maven {
credentials {
username nexusUsername
password nexusPassword
}
url 'https://edited'
}
}
dependencies {
classpath 'edited'
}
}
Could not GET 'https://edited.pom'. Received status code 403 from server: Forbidden
通过身份验证访问浏览器中给定的URL有效
据我所知,到目前为止,buildscript在构建的一开始就得到评估,因此,属性可能还没有加载?如果这是真的,如何加载它们?显然,问题是在两次运行之间,在
gradle.properties
中的密码末尾意外添加了额外的符号。工作正常。如果您想使用其他属性文件,如local.properties、gradle local.properties,则可采用变通方法。:1º)在项目rootdir中,添加新文件“add custom properties.gradle”: 如果需要,可以向上一个脚本添加逻辑。
2º)编辑/创建gradle-local.properties
repoUrl=https://a-url...
repoUser=a-user
repoPass=a-pass
3º)在build.gradle、settings.xml,。。。(内部构建脚本{…}):