Hello, I have problem with Java Plugin, here’s the situation: Image that we have to run a single class existed in the following defined SourceSets: build.gradle
sourceSets{
myproject{
java.srcDirs=[
//'admin_web',
'backend',
'shared',
'dashboard_web',
'gwt_common',
'surveys-backend',
'widgety',
//'test'
]
output.classesDir=file("$buildDir/war/WEB-INF/classes")
compileClasspath=configurations.myproject+configurations.unitTest+configurations.gwt
runtimeClasspath= output+compileClasspath
}
unitTest{
....
}
}
Then I have defined some configurations:
configurations {
myproject
liquibase
gwt
unitTest
}
and I have created the following task which going to execute a single class:
task catchAll(type:JavaExec){
doFirst{
println "Catchin all..."
println "Parsing ${projectDir}/customer_specific_data/user_profiles/${customer}/USER_PROFILES.xml"
}
main="com.myproject.server.pullman.taskmanager.adapters.CatchAll"
classpath{
[
sourceSets.myproject.output.classesDir,
configurations.myproject,
configurations.gwt,
configurations.liquibase,
]
}
args=[
"-instance",
"${customer}",
"-userProfiles",
"${projectDir}/customer_specific_data/user_profiles/${customer}/USER_PROFILES.xml",
"-force",
"-customerId",
"${customer}"
]
jvmArgs= [
"-Xmx1024M",
"-Xss1024k"
]
}
Finally my problem that the classpath fail to detect the suitable jars between these configurations needed for launching this class. I got an error relative to a classpath too much long… But if I create new configuration where I separate all these suitable jars it works:
configurations{
newconfig
}
dependencies
{
//all separated jars
}
<code>
task catchAll(type:JavaExec){
doFirst{
println "Catchin all..."
println "Parsing ${projectDir}/customer_specific_data/user_profiles/${customer}/USER_PROFILES.xml"
}
main="com.myproject.server.pullman.taskmanager.adapters.CatchAll"
classpath{
[
sourceSets.myproject.output.classesDir,
//instead of
configurations.myproject, or sourceSets.myproject.runtimeClasspath
configurations.newconfig
configurations.gwt,
configurations.liquibase,
]
}
args=[
"-instance",
"${customer}",
"-userProfiles",
"${projectDir}/customer_specific_data/user_profiles/${customer}/USER_PROFILES.xml",
"-force",
"-customerId",
"${customer}"
]
jvmArgs= [
"-Xmx1024M",
"-Xss1024k"
]
}
To conclude, if we include SouceSets.something.output.classesDir & SouceSets.something.runtimeClasspath in JavaExec it will not works but if we seperate the configuration from the SouceSets.something.runtimeClasspath it works.
Can someone explain us this situation? Thank you!!