How do I bundle the class files of a sub-project into a jar that isn't just a manifest?

Hi

I have a build file as below, and I am trying to generate one jar per sub-project – so bundle the compiled classes into a jar file (i need that since I need to do some specific post-processing on the jars).

My build file kinda does this, but the jar it generates is just a manifest, and not an actual jar – there is nothing in it except the manifest.

I must be missing something obvious, since I have the same problem using buildr.

Any help would be greatly appreciated.

thanks graham

def build = '/Users/graham/Documents/infoforge/build/'
def src = build + 'src'
def libBase = '/Users/graham/Documents_No_BUP/odslibs/'
  //
// Standard libs
//
  def LIB_JENA = "jena:jena:2.6.3"
def LIB_IRI = "iri:iri:0.8"
  //
// Project types
//
  configure(subprojects)
{
  proj ->
  apply plugin: 'java'
    sourceSets
   {
   main
    {
    java { srcDir src + proj.name + '/src' }
   }
  }
  repositories
  {
   flatDir
   {
     dirs libBase
    }
  }
}
  //
// Projects start here
//
  project(':api')
{
 dependencies
  {
  compile LIB_IRI
 }
}
  project(':util')
{
 dependencies
  {
  compile project(':api')
  compile LIB_JENA
  compile LIB_IRI
 }
}

The most likely cause is that the source directories aren’t configured correctly. Try something like:

task debug << {
  subprojects.each { println it.sourceSets.main.java.srcDirs }
}

Note that your code isn’t overriding the default source dir (‘srcDirs = [“some/dir”]’), but adding another one. But typically this isn’t a problem.

Yep the source sets were the problem, missing a “/”. Is there any way to force the java plugin to check that there is actual source to compile?

Nothing built-in, but it wouldn’t be hard to write your own check (perhaps as a script plugin) that iterates over the source sets’ directories and checks for their existence/non-emptiness.

(Or better, iterate over ‘compileTask.source’.) If there aren’t any source files, the compile task should always print ‘UP-TO-DATE’, which is a hint that something is wrong.