# JavaExec Classpath & SourceSets & Configurations Problem

**URL:** <https://discuss.gradle.org/t/javaexec-classpath-sourcesets-configurations-problem/844>\
**Category:** Old Forum Archive\
**Created:** [August 13, 2014, 2:10pm UTC](https://discuss.gradle.org/t/javaexec-classpath-sourcesets-configurations-problem/844 "2014-08-13T14:10:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Firas\_Fafi](https://avatars.discourse-cdn.com/v4/letter/f/7bcc69/32.png) [@Firas\_Fafi](https://discuss.gradle.org/u/Firas_Fafi)\
**Post date:** [August 13, 2014, 2:10pm UTC](https://discuss.gradle.org/t/javaexec-classpath-sourcesets-configurations-problem/844/1 "2014-08-13T14:10:00Z")

</div>

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

```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:

```gradle
configurations {
  myproject
  liquibase
  gwt
  unitTest
}

```

and I have created the following task which going to execute a single class:

```gradle
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:

```gradle
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!!
