android - 无法升级到 gradle 5 - 得到“项目名称 '../../' 不得包含以下任何字符:[/、\、:、<、>、”、?、*、|]。”
问题描述
我正在尝试升级到 gradle 5.1.1 并收到错误消息:项目名称 '../../' 不得包含以下任何字符: [/, \, :, <, >, ", ? , *, |].设置'rootProject.name'或调整'include'语句。
我在项目名称中找不到任何禁止的内容。该项目是一个 SDK。
毕业版本是:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
应用程序等级是:
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {
url "http://art01.corp.tity.com:8081/tory/inhouse/"
}
maven {
url "http://art01.corp.tity.com:8081/tory/repo"
}
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
模型gradle文件是:
import java.util.regex.Matcher
import java.util.regex.Pattern
apply plugin: 'com.android.library'
apply plugin: 'maven'
println GradleVersion.current().getVersion() + " - " + GradleVersion.current().getBuildTime() + " - " + GradleVersion.current().getRevision() + GradleVersion.current().isSnapshot() ? " - is snapshot" : ""
def isDebugBuild=0;
gradle.startParameter.taskNames.each {
taskName -> println "taskName=" + taskName
if (taskName.contains("Debug")){
isDebugBuild=1
}
}
def currentFlavor = ""
def appVersionCode = getVersionCode();
def coreAarFile
def mapFile = ""
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
def WEB_APP_NAME = "id"
println "project.name()=" + project.getName()
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode appVersionCode
versionName "1.4"
buildConfigField "String", "URL_ACCESS_NAME", "\"" + WEB_APP_NAME + "\""
}
def VAR_ENVIRONMENT = "ENVIRONMENT"
buildTypes {
debug {
buildConfigField "ch.qos.logback.classic.Level", "LOG_LEVEL", 'ch.qos.logback.classic.Level.DEBUG'
signingConfig signingConfigs.debug
minifyEnabled false
}
}
flavorDimensions "version"
productFlavors {
envTest {
dimension "version"
buildConfigField "String", VAR_URL_ACCESS_IP_US, '"' + TEST_SERVER_IP_US + '"'
manifestPlaceholders = [serverIpUS: TEST_SERVER_IP_US, serverIpEU: TEST_SERVER_IP_EU, serverIpAU: TEST_SERVER_IP_AU, servletName: WEB_APP_NAME]
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/*'
exclude 'META-INF/maven'
}
testOptions {
unitTests.returnDefaultValues = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
//LOGGING FACADE AND IMPLEMENTATION
implementation 'org.slf4j:slf4j-api:1.7.26'
implementation 'com.github.tony19:logback-android-core:1.1.1-6'
implementation('com.github.tony19:logback-android-classic:1.1.1-6') {
exclude group: 'com.google.android', module: 'android'
}
implementation 'org.bitbucket.b_c:jose4j:0.6.5'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'commons-codec:commons-codec:1.12'
implementation 'com.madgag.spongycastle:prov:1.58.0.0'
implementation 'com.google.android.gms:play-services-base:16.0.1'
implementation 'com.google.android.gms:play-services-safetynet:16.0.0'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'junit:junit:4.12'
}
def getVersionCode()
{
def Properties versionProps = new Properties()
def versionPropsFile = file('version.properties')
if (versionPropsFile.exists() && versionPropsFile.canRead()) {
versionProps.load(new FileInputStream(versionPropsFile))
} else {
throw new GradleException("Could not read version.properties!")
}
def code = (versionProps['VERSION_CODE'] ?: "0").toInteger()
return code
}
task('incrementVersionCode') << {
def Properties versionProps = new Properties()
def versionPropsFile = file('version.properties')
if (versionPropsFile.exists() && versionPropsFile.canRead()) {
versionProps.load(new FileInputStream(versionPropsFile))
} else {
throw new GradleException("Could not read version.properties!")
}
def code = (versionProps['VERSION_CODE'] ?: "0").toInteger() + 1
versionProps['VERSION_CODE'] = code.toString()
versionProps.store(versionPropsFile.newWriter(), null)
return code
}
currentFlavor = getCurrentFlavor()
println "currentFlavor=" + currentFlavor
def filePrefix=""
def fileFlavor=""
def fileBuildType=""
def mappingFilePath=""
filePrefix="$buildDir/outputs/aar/idsdkclient-"
if (currentFlavor.equals("EnvTest")){
fileFlavor="envTest"
}
if (isDebugBuild==1){
fileBuildType="debug"
}
println "aar file = " + filePrefix + fileFlavor + "-" + fileBuildType + ".aar"
coreAarFile = file(filePrefix + fileFlavor + "-" + fileBuildType + ".aar")
println "build file=" + coreAarFile.absolutePath + ", exists=" + coreAarFile.exists()
println 'Artifacts:'
configurations.findAll().each { config ->
config.allArtifacts.getFiles().each { file -> println "Artifact : ${config}: " + file }
}
artifacts {
archives coreAarFile
if (mappingFilePath.length()>0){
archives mappingFile
}
}
uploadArchives{
repositories {
mavenDeployer {
repository(url: TITY_MAVEN_REPO_INHOUSE_URL) {
if (maven_user != null && maven_password != null) {
authentication(userName: maven_user, password: maven_password)
} else {
authentication(userName: mavenUser, password: mavenPassword)
}
}
pom.groupId = 'com.tity.id.sdk'
pom.artifactId = "idsdkclient-" + fileFlavor + "-" + fileBuildType
println "pom.artifactId=" + pom.artifactId + ", android.defaultConfig.versionName = " + android.defaultConfig.versionName + ", android.defaultConfig.versionCode=" + android.defaultConfig.versionCode
pom.version = android.defaultConfig.versionName + '-b' + android.defaultConfig.versionCode
pom.packaging = 'aar'
}
}
}
def getCurrentFlavor() {
Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString()
Pattern pattern;
if( tskReqStr.contains( "assemble" ) )
pattern = Pattern.compile("assemble(\\w+)(Release|Debug)")
else
pattern = Pattern.compile("generate(\\w+)(Release|Debug)")
Matcher matcher = pattern.matcher( tskReqStr )
if( matcher.find() )
return matcher.group(1)
else
{
return "";
}
}
你能给些建议么?
解决方案
卖掉了。问题出在文件“settngs.gradle”中。有一行:
include ':idsdkclient',
应该:
include 'idsdkclient'
模型模型 gragle 的另一个问题:
task('incrementVersionCode') << {
..
}
应该:
task myTask {
doLast {
..
}
}
推荐阅读
- json - 熊猫的嵌套列表列表
- maven - 将自定义属性添加到 pom.properties
- python - 错误消息 Filedialog tkinter / FIFinderSyncExtensionHost 在两者中都实现
- r - system("timedatectl") "查询服务器失败:连接超时"
- javascript - 如果 JSON 数据不存在,如何隐藏 div
- java - 如何在团队城市插件开发jsp中处理表单提交
- php - php-amqplib:如何防止无限加载网页?
- java - Java 多环境最佳实践问题
- javascript - 是否可以在 Zapier Code 中启动服务器
- node.js - 解析大型 JSON 文件时两个 NodeJS 流之间的竞争条件