public SourceSetOutput getOutput() { return output; }
public void setMainClassSourceSetOutput(SourceSetOutput sourceSetOutput) { this.mainClassSourceSetOutput = sourceSetOutput; this.dependsOn(this.mainClassSourceSetOutput.getBuildDependencies()); }
/** Takes an action on a Bnd jar. */ private static void takeBndAction(Project project, Throwing.Consumer<aQute.bnd.osgi.Jar> onBuilder) { ProjectPlugin.getPlugin(project, JavaPlugin.class); Jar jarTask = (Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME); Errors.rethrow().run(() -> { try (Builder builder = new Builder()) { // set the base folder builder.setBase(project.getProjectDir()); // copy all properties from jar.manifest.attributes into the bnd Builder Attributes attr = jarTask.getManifest().getEffectiveManifest().getAttributes(); for (Map.Entry<String, Object> entry : attr.entrySet()) { builder.set(entry.getKey(), entry.getValue().toString()); } // set the classpath for manifest calculation Set<File> runtimeConfig = project.getConfigurations().getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME).getFiles(); builder.addClasspath(runtimeConfig); // put the class files and resources into the jar JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSetOutput main = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput(); // delete empty folders so that bnd doesn't make Export-Package entries for them deleteEmptyFoldersIfExists(main.getClassesDir()); deleteEmptyFoldersIfExists(main.getResourcesDir()); builder.set(Constants.INCLUDERESOURCE, main.getClassesDir() + "," + main.getResourcesDir()); // set the version if (builder.getBundleVersion() == null) { try { String version = project.getVersion().toString(); if (version.endsWith("-SNAPSHOT")) { version = version.replace("-SNAPSHOT", ".I" + dateQualifier()); } builder.setBundleVersion(version); } catch (Exception e) { project.getLogger().warn(e.getMessage() + " Must be 'major.minor.micro.qualifier'"); builder.setBundleVersion("0.0.0.ERRORSETVERSION"); } } // take an action with the builder onBuilder.accept(builder.build()); } }); }
public void setOutput(SourceSetOutput output) { this.output = output; }