gpt4 book ai didi

java - 无法将任务 'X'添加为具有该名称的任务

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

我有这个gradle.build

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'maven-publish'
apply from: ext.gradleDir + '/common.gradle'
apply from: ext.gradleDir +'/base.gradle'
apply from: ext.gradleDir + '/integration_test.gradle'

sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '1.0'

project.archivesBaseName = 'client-services-lib'
uploadArchives.repositories.mavenDeployer.pom.groupId="com.waze.automation"


dependencies {
compile('com.waze.automation:common:1.0.58')

compile('com.sun.jersey:jersey-bundle:1.19')
compile('com.sun.jersey:jersey-json:1.19')
compile group: 'org.codehaus.jackson', name:'jackson-jaxrs', version: '1.1.1'

compile('com.google.guava:guava:18.0')

testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile('org.hamcrest:hamcrest-all:1.3')
testCompile('org.mockito:mockito-all:1.9.5')

}

war {
from 'src/main' // include source files in war
}

我运行这个
❯ ./gradlew build -i                                                                                                                                                                                                                      [12:40:40]
Starting Build
Settings evaluated using settings file '/Users/eladb/WorkspaceQa/java/MobileAutomationWebService/settings.gradle'.
Projects loaded. Root project using empty build file.
Included projects: [root project 'MobileAutomationWebService', project ':library-services', project ':web-services']
Evaluating root project 'MobileAutomationWebService' using empty build file.
Evaluating project ':library-services' using build file '/Users/eladb/WorkspaceQa/java/MobileAutomationWebService/library-services/build.gradle'.
Compiling build file '/Users/eladb/WorkspaceQa/java/MobileAutomationWebService/library-services/build.gradle' using StatementExtractingScriptTransformer.
Compiling build file '/Users/eladb/WorkspaceQa/java/MobileAutomationWebService/library-services/build.gradle' using BuildScriptTransformer.

FAILURE: Build failed with an exception.

* Where:
Script '/Users/eladb/WorkspaceQa/gradle/base.gradle' line: 28

* What went wrong:
A problem occurred evaluating script.
> Cannot add task ':library-services:wrapper' as a task with that name already exists.

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

和这个 base.gradle
project.ext.flag = { String name ->
if (!project.hasProperty(name)) {
return false
}

String value = project.ext[name]
value = value.toLowerCase()

if (value == "true" || value == "yes" || value == "1") {
return true
}

if (value == "false" || value == "no" || value == "0" || value == "") {
return false
}

throw new IllegalArgumentException("Invalid value of flag property \"$name\": \"$value\", must be one of true, false, yes, no, 0, 1 or empty")
}

////////////////////////////////////////////////////////////////////////////////////////
// Standard settings (can be overridden on a per-project basis)
////////////////////////////////////////////////////////////////////////////////////////

sourceCompatibility = 1.6

compileJava.options.encoding = 'UTF-8'

task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}

////////////////////////////////////////////////////////////////////////////////////////
// Waze "Be Fast" (tm)
////////////////////////////////////////////////////////////////////////////////////////
configurations.all {
if (flag('waze.beFast')) {
resolutionStrategy.cacheDynamicVersionsFor 1, 'hours'
}
else {
resolutionStrategy.cacheDynamicVersionsFor 0, 'minutes'
}
}

////////////////////////////////////////////////////////////////////////////////////////
// Common repositories config.
////////////////////////////////////////////////////////////////////////////////////////
repositories {
mavenCentral()
maven {
url getWazeRepoUrl()
}
maven {
url "http://www.hibernatespatial.org/repository"
}
}

def getWazeRepoUrl() {
if (project.hasProperty('buildMachine')) {
"/data/archiva/repositories/internal/"
} else {
"https://waze-repo.corp.google.com/archiva/repository/internal/"
}
}

////////////////////////////////////////////////////////////////////////////////////////
// Add 'provided' scope which is missing from Gradle by default.
////////////////////////////////////////////////////////////////////////////////////////
configurations {
provided
}

sourceSets {
main {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
}
test {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
}
}

////////////////////////////////////////////////////////////////////////////////////////
// Eclipse-specific configuration.
////////////////////////////////////////////////////////////////////////////////////////
if (hasProperty('web') && web) {
apply plugin: 'eclipse-wtp'
} else {
apply plugin: 'eclipse'
}

tasks.eclipse.dependsOn(cleanEclipse)

eclipse {
pathVariables 'GRADLE_USER_HOME': gradle.gradleUserHomeDir

classpath {
plusConfigurations += [configurations.provided]
noExportConfigurations += [configurations.provided]
}
}
project.afterEvaluate {
// use jre lib matching version used by project, not the workspace default
if (project.sourceCompatibility != null) {
def target = project.targetCompatibility.toString()
def containerPrefix = "org.eclipse.jdt.launching.JRE_CONTAINER"
def containerSuffix = '/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-' + target
if (containerSuffix != null) {
project.eclipse.classpath {
containers.removeAll { it.startsWith(containerPrefix) }
containers.add(containerPrefix + containerSuffix)
}
}
}
}

////////////////////////////////////////////////////////////////////////////////////////
// IntelliJ-specific configuration.
////////////////////////////////////////////////////////////////////////////////////////
if (flag('waze.idea')) {
apply plugin: 'idea'

idea {
module {
scopes.PROVIDED.plus += [configurations.provided]
}
}
}

我不明白为什么它说 Cannot add task ':library-services:wrapper' as a task with that name already exists.
我什至看不到gradle.build甚至尝试添加 "wrapping"任务

我的gradle.build不会尝试添加任务“包装器”
而且它没有出现在base.gradle'行:28

最佳答案

您是否将base.gradle应用于所有子项目?您也将其应用于根项目吗?

gradle中的包装器任务仅添加到根项目,而不添加到子项目。如果将base.gradle应用于所有项目,则可能是问题的原因。

关于java - 无法将任务 'X'添加为具有该名称的任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36176279/

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