How to integrate Gradle to my processes

Dear All,

I have recently started using gradle in a Java project (with eclipse). So far, all the sources reside on an online repository (git-based) that links directly to eclipse.

Since more deployment features are required, using gradle was a no-brainer. After spending some time I managed to create a build file that realises the existing structure, compiles and runs everything from the terminal.

However. I find it very difficult to merge eclipse and gradle together. By default, the project will have to be online (and will imported on eclipse for old and new users). Want I wanted to do is integrate gradle into the loop so as to be able to compile and run everything (via gradle) either from eclipse, or from the terminal (in the future, I would like to integrate gradle wraper too, unless now is a good moment should you advise so).

When I try to import on eclipse the project as a gradle project, it builds fine and runs from the gradle menu, but not from the standard eclipse ‘play’ button (on eclipse it looks like there are errors in the source, but this happens because from the gradle build eclipse does add the dependences on eclipse’s classpath, the depedences appear as gradle dependencies, which is wrong).

A quick win would be just to add the gradle file on the eclipse project space and use it only from terminal (however the contents of the gradle file will not be updated should I perform any changes to the files and/or libraries)

So… is there any way to use my build.gralde into my current project compilation and designate on eclipse that from now gradle will build and run everything?) Obviously this will help in testing etc etc…

Any ideas?

Currently my build.gradle looks like

apply plugin: 'java’
apply plugin: ‘eclipse’

sourceSets {
main {
java {
srcDir ‘src/ieee1516e’
}
}
}

dependencies {
compile files(‘lib/portico.jar’)
compile files(‘lib/traci4j.jar’)
}

task showEnvironmentalVariables{
description 'Displays all the required evironmental variables.'
println "JAVA_HOME: $System.env.JAVA_HOME"
println “RTI_HOME: $System.env.RTI_HOME”
}

task executeTest (dependsOn: ‘classes’, type: JavaExec) {
standardInput = System.in //to link user input
main = 'ieee1516e.testerFederate’
classpath = sourceSets.main.runtimeClasspath
println ‘classpath’ + sourceSets.main.runtimeClasspath.asPath
}

task executeVehicle (dependsOn: ‘classes’, type: JavaExec) {
standardInput = System.in //to link user input
main = 'ieee1516e.VehicleFederate’
classpath = sourceSets.main.runtimeClasspath
println ‘classpath’ + sourceSets.main.runtimeClasspath.asPath
}

defaultTasks ‘executeTest’

Many Thanks in advance,
CT