Gradle& Log4j - 尝试构建时不支持Major.minor版本51.0

时间:2015-09-29 11:44:58

标签: java gradle build.gradle unsupported-class-version

我正在使用gradle来构建和分发项目,但每当我尝试使用build命令时,我都会收到错误。

以下是错误消息:

C:\Users\jamatic\workspace\PersonModule>gradle clean build cleaneclipse eclipse
--stacktrace
:clean
:compileJava
error: Exception thrown while constructing Processor object: org/apache/logging/
log4j/core/config/plugins/processor/PluginProcessor : Unsupported major.minor ve
rsion 51.0
:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compile
Java'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExec
uter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.exec
ute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execut
e(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecu
ter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter
.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execut
e(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter
.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTa
skWorker.execute(DefaultTaskGraphExecuter.java:203)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTa
skWorker.execute(DefaultTaskGraphExecuter.java:185)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.processTask(AbstractTaskPlanExecutor.java:62)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.run(AbstractTaskPlanExecutor.java:50)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(Defaul
tTaskPlanExecutor.java:25)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(Defau
ltTaskGraphExecuter.java:110)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTask
ExecutionAction.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:37)
        at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExec
uter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecu
ter.java:43)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildEx
ecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:30)
        at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLa
uncher.java:158)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:52)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:155)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGra
dleLauncher.java:36)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
eLauncher.java:103)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
eLauncher.java:97)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:62)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
Launcher.java:97)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
cher.java:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
troller.run(InProcessBuildActionExecuter.java:102)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(Exe
cuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildA
ctionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:47)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:32)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(Contin
uousBuildActionExecuter.java:77)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(Contin
uousBuildActionExecuter.java:47)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.exe
cute(DaemonUsageSuggestingBuildActionExecuter.java:51)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.exe
cute(DaemonUsageSuggestingBuildActionExecuter.java:28)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.jav
a:170)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRunti
meValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRunti
meValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
ortingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots
trap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j
ava:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Com
pilation failed; see the compiler error output for details.
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJava
Compiler.java:47)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJava
Compiler.java:33)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegat
eAndHandleErrors(NormalizingJavaCompiler.java:101)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute
(NormalizingJavaCompiler.java:50)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute
(NormalizingJavaCompiler.java:36)
        at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.exe
cute(CleaningJavaCompilerSupport.java:34)
        at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.exe
cute(CleaningJavaCompilerSupport.java:25)
        at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompi
le.java:157)
        at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:139
)
        at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:93)

        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:243)

        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:230)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:61)
        ... 57 more


BUILD FAILED

Total time: 4.027 secs

C:\Users\jamatic\workspace\PersonModule>

我检查了build.gradle文件,发现源兼容性为1.6。这是我的Gradle构建文件:

/*** Gradle build file for PersonModule ***/

apply plugin: 'java'
apply plugin: 'java-library-distribution'
apply plugin: 'eclipse'

sourceCompatibility = 1.6

version = '2.2.5.5'

repositories {
    mavenCentral();

    ivy {
        url "Y://dev/shared-libs/ivy2"
    }
}

dependencies {
    compile 'no.solarsoft.admit.client:Venus2Core2:2.0+'
}

jar {
    // Keep jar clean:
    exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF'

    manifest {
       attributes 'Main-Class': 'no.solarsoft.venus2.application.personmodule.PersonModule',
                  'Class-Path': configurations.runtime.files.collect { "lib/$it.name" }.join(' ')
    }
}

我还检查了java版本和java构建路径:

ERROR: Oracle Weblogic Server port is already in use

Java version

我希望有人可以帮我找到解决此错误的方法。谢谢!

P.S我认为这个问题在某种程度上与其他不受支持的主要问题不同。

1 个答案:

答案 0 :(得分:4)

查看PluginProcessor类,这会导致错误。它是一个与Log4j2相关的类,因为库版本2.4需要Java 7.看起来,你的一些依赖项或子项目依赖于Log4j2版本大于或等于2.4。