1

I am trying to convert .classpath to a gradle project(The project is a dynamic web application, using Spring). I am getting the following error.

./gradlew tasks
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details

FAILURE: Build failed with an exception.

* Where:
Build file '/home/jsiddharth/workspace/feature_multiple_web_admins/mnoxwebadmin/BuseetaWebAdmin/build.gradle' line: 20

* What went wrong:
A problem occurred evaluating root project 'BuseetaWebAdmin'.
> Could not find method compile() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

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

BUILD FAILED

Total time: 12.838 secs

My .classpath is

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src/main/java">
        <attributes>
            <attribute name="FROM_GRADLE_MODEL" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" path="src/main/resources">
        <attributes>
            <attribute name="FROM_GRADLE_MODEL" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" path="src/test/java">
        <attributes>
            <attribute name="FROM_GRADLE_MODEL" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" path="src/test/resources">
        <attributes>
            <attribute name="FROM_GRADLE_MODEL" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
    <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer">
        <attributes>
            <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
        </attributes>
    </classpathentry>
    <classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
            <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
        </attributes>
    </classpathentry>
    <classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    <classpathentry exported="true" kind="var" path="localjar">
        <attributes>
            <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
        </attributes>
    </classpathentry>


    .. bunch of other local jar's ..


    <classpathentry exported="true" kind="var" path="mCruiseOnLibs/json-simple-1.1.1.jar">
        <attributes>
            <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
        </attributes>
    </classpathentry>
    <classpathentry exported="true" kind="var" path="mCruiseOnLibs/javax.json-1.0.2.jar">
        <attributes>
            <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
        </attributes>
    </classpathentry>
    <classpathentry combineaccessrules="false" exported="true" kind="src" path="/localproject"/>

    .. bunch of local projects referred ..

    <classpathentry kind="output" path="bin"/>
</classpath>

Gradle build file

buildscript{

    //def dropboxfolder = "/home/jsiddharth/Dropbox/mylibs"

    repositories {
        jcenter()
        mavenCentral()
    }

    dependencies {
        // I copied all local jar's to the libs folder that contains the build.gradle file.
        compile fileTree(dir: 'libs', include: '*.jar')

        // compile files('${dropboxfolder}/local.jar'), this did not work, so commented

        compile(project(':localproject'))
        testCompile 'junit:junit:4.12'
    }
}

apply plugin:'java'
apply plugin : 'war'
Siddharth
  • 9,349
  • 16
  • 86
  • 148

1 Answers1

1

The dependencies for the program to build must be specified outside of the buildscript block:

buildscript{

    //def dropboxfolder = "/home/jsiddharth/Dropbox/mylibs"

    repositories {
        jcenter()
        mavenCentral()
    }
}

apply plugin:'java'
apply plugin : 'war'

repositories {
    jcenter()
    mavenCentral()
}

dependencies {
    // I copied all local jar's to the libs folder that contains the build.gradle file.
    compile fileTree(dir: 'libs', include: '*.jar')

    // compile files('${dropboxfolder}/local.jar'), this did not work, so commented

    compile(project(':localproject'))
    testCompile 'junit:junit:4.12'
}

Dependencies inside the buildscript block are used for the build script itself.

Btw. all that has nothing to do with the .classpath file used by eclipse.

Henry
  • 42,982
  • 7
  • 68
  • 84