use of org.gradle.external.javadoc.MinimalJavadocOptions in project crnk-framework by crnk-project.
the class DocletPlugin method apply.
@Override
public void apply(final Project project) {
Configuration config = project.getConfigurations().create("crnkJavaDocToXml");
project.getDependencies().add("crnkJavaDocToXml", "com.github.markusbernhardt:xml-doclet:1.0.5");
Javadoc task = project.getTasks().create(TASK_NAME, Javadoc.class);
task.setTitle(null);
task.setDestinationDir(new File(project.getBuildDir(), "crnk-xml-docs"));
MinimalJavadocOptions options = task.getOptions();
options.setDoclet("com.github.markusbernhardt.xmldoclet.XmlDoclet");
options.setMemberLevel(JavadocMemberLevel.PRIVATE);
options.setDocletpath(new ArrayList<>(config.getFiles()));
SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
SourceSet mainSourceSet = sourceSets.getByName("main");
task.source(mainSourceSet.getAllJava());
task.setClasspath(mainSourceSet.getCompileClasspath());
}
use of org.gradle.external.javadoc.MinimalJavadocOptions in project gradle-plugins by freefair.
the class ResolveJavadocLinks method addLink.
private void addLink(String link) {
MinimalJavadocOptions options = javadoc.getOptions();
if (options instanceof StandardJavadocDocletOptions) {
StandardJavadocDocletOptions docletOptions = (StandardJavadocDocletOptions) options;
List<String> links = docletOptions.getLinks();
if (links == null || !links.contains(link)) {
logger.debug("Adding '{}' to {}", link, javadoc);
docletOptions.links(link);
} else {
logger.info("Not adding '{}' to {} because it's already present", link, javadoc);
}
}
}
use of org.gradle.external.javadoc.MinimalJavadocOptions in project gradle-baseline by palantir.
the class BaselineModuleJvmArgs method apply.
@Override
@SuppressWarnings("checkstyle:MethodLength")
public void apply(Project project) {
project.getPluginManager().withPlugin("java", unused -> {
BaselineModuleJvmArgsExtension extension = project.getExtensions().create(EXTENSION_NAME, BaselineModuleJvmArgsExtension.class, project);
// javac isn't provided `--add-exports` args for the time being due to
// https://github.com/gradle/gradle/issues/18824
// However, we set sourceCompatibility in BaselineJavaVersion to opt out of the '--release' flag.
project.getExtensions().getByType(SourceSetContainer.class).configureEach(sourceSet -> {
TaskProvider<JavaCompile> javaCompileProvider = project.getTasks().named(sourceSet.getCompileJavaTaskName(), JavaCompile.class);
javaCompileProvider.configure(javaCompile -> {
javaCompile.getOptions().getCompilerArgumentProviders().add(new CommandLineArgumentProvider() {
@Override
public Iterable<String> asArguments() {
// The '--release' flag is set when BaselineJavaVersion is not used.
if (!project.getPlugins().hasPlugin(BaselineJavaVersion.class)) {
project.getLogger().debug("BaselineModuleJvmArgs not applying args to compilation task " + "{} on {} due to lack of BaselineJavaVersion", javaCompile.getName(), project);
return ImmutableList.of();
}
ImmutableList<String> arguments = collectCompilationArgs(project, extension, sourceSet);
project.getLogger().debug("BaselineModuleJvmArgs compiling {} on {} with exports: {}", javaCompile.getName(), project, arguments);
return arguments;
}
});
});
TaskProvider<Task> javadocTaskProvider = null;
try {
javadocTaskProvider = project.getTasks().named(sourceSet.getJavadocTaskName());
} catch (UnknownTaskException e) {
// skip
}
if (javadocTaskProvider != null) {
javadocTaskProvider.configure(javadocTask -> {
javadocTask.doFirst(new Action<Task>() {
@Override
public void execute(Task task) {
// The '--release' flag is set when BaselineJavaVersion is not used.
if (!project.getPlugins().hasPlugin(BaselineJavaVersion.class)) {
project.getLogger().debug("BaselineModuleJvmArgs not applying args to compilation task " + "{} on {} due to lack of BaselineJavaVersion", task.getName(), project);
return;
}
Javadoc javadoc = (Javadoc) task;
MinimalJavadocOptions options = javadoc.getOptions();
if (options instanceof CoreJavadocOptions) {
CoreJavadocOptions coreOptions = (CoreJavadocOptions) options;
ImmutableList<JarManifestModuleInfo> info = collectClasspathInfo(project, sourceSet);
List<String> exportValues = Stream.concat(// Compilation only supports exports, so we union with opens.
Stream.concat(extension.exports().get().stream(), extension.opens().get().stream()), info.stream().flatMap(item -> Stream.concat(item.exports().stream(), item.opens().stream()))).distinct().sorted().map(item -> item + "=ALL-UNNAMED").collect(ImmutableList.toImmutableList());
project.getLogger().debug("BaselineModuleJvmArgs building {} on {} " + "with exports: {}", javadoc.getName(), project, exportValues);
if (!exportValues.isEmpty()) {
coreOptions.addMultilineStringsOption("-add-exports").setValue(exportValues);
}
} else {
project.getLogger().error("MinimalJavadocOptions implementation was " + "not CoreJavadocOptions, rather '{}'", options.getClass().getName());
}
}
});
});
}
});
project.getTasks().withType(Test.class).configureEach(new Action<Test>() {
@Override
public void execute(Test test) {
test.getJvmArgumentProviders().add(new CommandLineArgumentProvider() {
@Override
public Iterable<String> asArguments() {
ImmutableList<String> arguments = collectClasspathArgs(project, extension, test.getClasspath(), OpensMode.RUNTIME);
project.getLogger().debug("BaselineModuleJvmArgs executing {} on {} with exports: {}", test.getName(), project, arguments);
return arguments;
}
});
}
});
project.getTasks().withType(JavaExec.class).configureEach(new Action<JavaExec>() {
@Override
public void execute(JavaExec javaExec) {
javaExec.getJvmArgumentProviders().add(new CommandLineArgumentProvider() {
@Override
public Iterable<String> asArguments() {
ImmutableList<String> arguments = collectClasspathArgs(project, extension, javaExec.getClasspath(), OpensMode.RUNTIME);
project.getLogger().debug("BaselineModuleJvmArgs executing {} on {} with exports: {}", javaExec.getName(), project, arguments);
return arguments;
}
});
}
});
project.getTasks().withType(Jar.class).configureEach(new Action<Jar>() {
@Override
public void execute(Jar jar) {
jar.doFirst(new Action<Task>() {
@Override
public void execute(Task task) {
jar.manifest(new Action<Manifest>() {
@Override
public void execute(Manifest manifest) {
addManifestAttribute(jar, manifest, ADD_EXPORTS_ATTRIBUTE, extension.exports());
addManifestAttribute(jar, manifest, ADD_OPENS_ATTRIBUTE, extension.opens());
}
});
}
});
}
});
});
}
Aggregations