Home Comments

Support for multiple output directories and source sets with ice-builder-gradle

timpatttimpatt Member Tim PattersonOrganization: DSTOProject: Simulation Architecture
Hi there!

We've used an internally developed gradle plugin that leverages the ice-ant task for a while now, however we've been looking at moving to use the official ice-builder-gradle plugin instead.

We've hit a minor snag with the currently implementation, however - namely that the plugin only supports a single, "global" output directory for generated source files ("slice.output"), and
doesn't allow setting it per-"Ice sourceSet". The plugin also implicitly binds the "slice.output" to the input of the "project.sourceSets.main.java" sourceSet, which may not be what
you want to do.

I understand that this is an early version of the plugin, but I wonder if I may be so bold as to suggest a slightly different alternative to the "sourceSet" organisation
based on our experience with our internally developed plugin?

Our internally developed plugin is based on the mechanism used by the standard ANTLR gradle plugin. It extends the standard gradle sourceSet to allow you to do the following:

sourceSets {
main {
slice {
srcDir "${someNonStandard.sliceDir}"
args "${someNonStandardArgs}"
outputDirectory "${someNonStandard.outputDirectory}"
// etc
}
java {
srcDir "${someNonStandardJavaDir}"
}
}
test {
slice { // srcDir defaults to "src/main/slice"
}
java { // ...
}
}
}

The advantage of this approach is that it ties the appropriate generated slice2java code to the appropriate java sourceSet automatically. The sourceSet names "main" and "test" are just
convention, but otherwise arbitrary, allowing extensions and other kinds of configurations to be managed by the end-user. Finally, this approach follows the convention used by the
standard gradle plugins - so the end user won't be required to learn a new way of doing things, and will "just work" with minimal configuration.

I'm yet to find a disadvantage with this approach - with a provisio: we are currently only using gradle to manage our java builds. I'm not sure how it fares outside of this use-case...

Thanks,

Tim.

Comments

  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    Hi Tim,

    Thanks for the suggestion on how to improve the Ice Builder for Gradle. Having the ability to set different output directories for different source sets sounds like a good idea. If you are interested in making this change to the plugin we actively support and encourage user contributions. Please see CONTRIBUTING.md for more information on how to contribute to Ice Builder for Gradle.

    Regards
Sign In or Register to comment.