在构建java项目时在gradle中获取异常

时间:2015-02-07 10:35:19

标签: java gradle

我正在使用gradle并退出使用它。我已经在他们的网站上安装了最新版本,并按照gradle的官方tutorails开始使用。但是在构建java项目时遇到了问题。我搜索过但找不到任何有用的解决方案。当我运行'gradle build'时,它应该在根目录下构建java项目,但它会出现以下错误。

FAILURE: Build failed with an exception.
* What went wrong:
org/gradle/internal/service/scopes/PluginServiceRegistry

构建文件配置为:

apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.5
version = '1.0'
jar {
manifest {
    attributes 'Implementation-Title': 'Gradle Quickstart',
               'Implementation-Version': version
}
}

repositories {
mavenCentral()
}

dependencies {
compile group: 'commons-collections', name: 'commons-collections', version:               '3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
}

test {
systemProperties 'property': 'value'
}

uploadArchives {
repositories {
   flatDir {
       dirs 'repos'
   }
}
}

异常的Stacktrace是

* Exception is:
java.lang.NoClassDefFoundError: org/gradle/internal/service/scopes/PluginService
Registry
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.gradle.internal.service.ServiceLocator.findServiceImplementations
(ServiceLocator.java:109)
        at org.gradle.internal.service.ServiceLocator.findFactoriesForServiceTyp
e(ServiceLocator.java:75)
        at org.gradle.internal.service.ServiceLocator.getAll(ServiceLocator.java
:45)
        at org.gradle.internal.service.scopes.GlobalScopeServices.configure(Glob
alScopeServices.java:71)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
        at org.gradle.internal.service.DefaultServiceRegistry.invoke(DefaultServ
iceRegistry.java:328)
        at org.gradle.internal.service.DefaultServiceRegistry.findConfigureMetho
d(DefaultServiceRegistry.java:149)
        at org.gradle.internal.service.DefaultServiceRegistry.findProviderMethod
s(DefaultServiceRegistry.java:119)
        at org.gradle.internal.service.DefaultServiceRegistry.addProvider(Defaul
tServiceRegistry.java:227)
        at org.gradle.internal.service.ServiceRegistryBuilder.build(ServiceRegis
tryBuilder.java:52)
        at org.gradle.launcher.cli.BuildActionsFactory.runBuildInProcess(BuildAc
tionsFactory.java:159)
        at org.gradle.launcher.cli.BuildActionsFactory.createAction(BuildActions
Factory.java:133)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
createAction(CommandLineActionFactory.java:242)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
execute(CommandLineActionFactory.java:232)
        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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        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: java.lang.ClassNotFoundException: org.gradle.internal.service.scopes.
PluginServiceRegistry
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 47 more

我的jdk版本是1.8.0,gradle版本是2.2.1。 任何帮助将受到高度赞赏。

0 个答案:

没有答案