rosjava - How to compile multiple message projects into a single jar?

asked 2014-05-15 07:23:18 -0500

csherstan gravatar image

updated 2014-05-15 07:33:31 -0500

I have a message project: bento_controller, whose messages depend on dynamixel_msgs. I can add both bento_controller and dynamixel_msgs to a rosjava project: bento_java.

This generates two jars, one for bento_controller and the other for dynamixel_msgs. I would like to output a single jar (bento.jar) that combines these two.

I have figured out how to combine both of these jars into a single jar using a gradle task where I explicitly run that task using gradle. What I would like to do is be able to output the combined jar when I run catkin_make rather than having the extra step of running gradle.

I'm new to gradle and rosjava, I've been looking through the source for rosjava but haven't figured out any way to do it yet.

I have added the following to my root build.gradle:

task allJar(type: Jar, dependsOn: subprojects.assemble) {
    println "allJar"
    baseName = 'bento_java'
    version = jarVersion
    subprojects.each { subproject -> 
       from subproject.configurations.archives.allArtifacts.files.collect {
          zipTree(it)
       }
    }
}

artifacts {
  archives allJar
}

However, allJar is executed before the tasks that build the two individual jars. Perhaps I just need a different dependency?

Thanks, Craig

edit retag flag offensive close merge delete