Question

I have a project that only builds the fat onejar file for testing purposes. Thus, there's a separate testing class that I don't want as a dependency to the main source, but I do want it included into the onejar. Odd scenario, I know.

I'm using the com.smokejumperit.gradle.OneJarPlugin plugin (source here), and clearly it gets the list of files to include in the onejar here:

project.task('oneJar', dependsOn:[project.tasks.jar, project.tasks.typedefOneJar]) {
    ...
    inputs.files([jar.outputs.files, project.configurations.getByName("compile"), project.configurations.getByName("runtime")])

jar.output.files is used for publishing, so I don't want a this second jar file being published, and the two project.configurations would define dependencies for the main source jar, and I don't want this second jar to be a dependency of that either.

This second jar file is built with a task:

task integrationJar(type: Jar) {
    from sourceSets.integrationTest.output
    classifier = 'integration'
}

... so I can access the resulting FileCollection via integrationJar.outputs.files. If there was a clear way to add that to oneJar.input.files, I'd be golden, but I can't figure out how to do that. I've tried something like this:

oneJar {
    dependsOn 'integrationJar'
    println integrationJar.outputs.files.getAsPath()
    inputs.files.add(integrationJar.outputs.files)
    println inputs.files.getAsPath()
}

... but the result for the last print is still missing the integration jar file.

Ideas?

Était-ce utile?

La solution

I'm not familiar with the implementation of that plugin, but I'd be surprised if inputs.files determined what gets included. (Usually, inputs is just consumed by Gradle's up-to-date check.) I recommend to try the gradle-one-jar plugin, which appears to be more flexible.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top