2

だから、私のbuild.gradle見た目はこんな感じです。

task compile(type: Compile){
    dependsOn 'clean', 'init'

    classpath = files('bin', 
                    'lib\\foo-agent-dist-2.0.0-SNAPSHOT.jar',
                    'lib\\foo-common-2.0.0-SNAPSHOT.jar',
                    'lib\\foo-communication-api-2.0.0-SNAPSHOT.jar',
                    'lib\\spring-beans-3.1.2.RELEASE.jar',
                    'lib\\spring-context-3.1.2.RELEASE.jar',
                    'lib\\spring-web-3.1.2.RELEASE.jar',
                    'lib\\sqljdbc4-3.0.jar')
    destinationDir = file('bin')
    source = fileTree('src')
    sourceCompatibility = '1.7'
    targetCompatibility = '1.7'
}

task clean(type: Delete){
    delete 'bin'
}

task init(type: Copy){
    //TODO: Create "bin" directory if it doesn't exist
    from 'src'
    into 'bin'
    exclude '**/*.java', '**/*.bak'
    includeEmptyDirs = false
}

タスクを実行するとcompile、次の例外が発生します

[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks: 
[sts]      :compile
[sts] -----------------------------------------------------
:clean
:init
:compile

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':compile'.
> No value has been specified for property 'dependencyCacheDir'.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskValidationException: A problem was found with the configuration of task ':compile'.
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:247)
    at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:192)
    at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:177)
    at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:83)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:36)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
    at org.gradle.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter$1.run(TaskCacheLockHandlingBuildExecuter.java:31)
    at org.gradle.cache.internal.DefaultCacheAccess$1.create(DefaultCacheAccess.java:111)
    at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:126)
    at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:109)
    at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:103)
    at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
    at org.gradle.api.internal.changedetection.TaskCacheLockHandlingBuildExecuter.execute(TaskCacheLockHandlingBuildExecuter.java:29)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:155)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:110)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:78)
    at org.gradle.tooling.internal.provider.ExecuteBuildAction.run(ExecuteBuildAction.java:31)
    at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:94)
    at org.gradle.launcher.daemon.protocol.Build.run(Build.java:68)
    at org.gradle.launcher.daemon.protocol.Build.run(Build.java:64)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:45)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:28)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$4.call(ForwardClientInput.java:116)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$4.call(ForwardClientInput.java:114)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:114)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:61)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.HandleClientDisconnectBeforeSendingCommand.execute(HandleClientDisconnectBeforeSendingCommand.java:21)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.StopConnectionAfterExecution.execute(StopConnectionAfterExecution.java:27)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
    at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:55)
    at org.gradle.launcher.daemon.server.Daemon$1$1.run(Daemon.java:123)
    at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
Caused by: org.gradle.api.InvalidUserDataException: No value has been specified for property 'dependencyCacheDir'.
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:46)
    ... 68 more


BUILD FAILED

dependencyCacheDirJava プロジェクトをコンパイルする際に を定義する必要があるのはなぜですか? また、依存キャッシュ ディレクトリを定義すると、System Java Compiler が見つからないというエラーが表示されます。

何?どうして!?何を与える、グラドル?この経験全体は非常にイライラし、不必要に複雑でした..完全にあきらめようとしています.

4

4 に答える 4

4

Java プラグインの使用を決定する必要がある場合:

apply plugin : 'java'

sourceCompatibility = '1.7'
targetCompatibility = '1.7'

sourceSets {
   main {
      java {
         srcDirs = ['src']
      }
   }
}

buildDir = 'bin'

repositories {
    flatDir dirs: 'lib'
}

dependencies {
    compile ':foo-agent-dist:2.0.0-SNAPSHOT',
            ':foo-common:2.0.0-SNAPSHOT',
            ':foo-communication-api:2.0.0-SNAPSHOT',
            ':spring-beans:3.1.2.RELEASE',
            ':spring-context:3.1.2.RELEASE',
            ':spring-web:3.1.2.RELEASE',
            ':sqljdbc4:3.0'
}
于 2012-09-08T11:38:09.313 に答える
3

JavaCompileタスク タイプを使用すると、おそらくうまくいくでしょう。

于 2013-07-19T23:53:55.170 に答える
2

これは私にとってはうまくいきます。これを例としてコードに必要な変更を適用するだけです

apply plugin: 'java'

configurations {
     querydslapt
}

sourceSets {
     target
}

sourceSets.target.java.srcDirs = ['src/main/target']


dependencies {
    compile ...libraries....

        querydslapt 'com.mysema.querydsl:querydsl-apt:2.7.1'

    testCompile project(':fastappoint-test')
}

task generateQueryDSL(type: Compile, group: 'build', description: 'Generates the QueryDSL query types') {
         source = sourceSets.main.java
         classpath = configurations.compile + configurations.querydslapt
         options.compilerArgs = [
                "-proc:only",
                "-processor", "com.mysema.query.apt.jpa.JPAAnnotationProcessor"
         ]
         destinationDir = sourceSets.target.java.srcDirs.iterator().next()
         dependencyCacheDir = new File(destinationDir, "dependencyCacheDir")
}
compileJava.dependsOn generateQueryDSL
于 2013-09-29T18:52:28.047 に答える
2

なぜ Java プラグインを使用しないのですか? すべてを手動で構成するには、さらに手間がかかります。

「システム Java コンパイラ」エラーについてサポートが必要な場合は、エラー メッセージとスタック トレースを投稿してください。

于 2012-09-06T17:31:22.413 に答える