org.anarres.gradle.plugin.stdproject.StdModulePlugin Maven / Gradle / Ivy
package org.anarres.gradle.plugin.stdproject;
import be.insaneprogramming.gradle.animalsniffer.AnimalSnifferExtension;
import be.insaneprogramming.gradle.animalsniffer.AnimalSnifferPlugin;
import com.bmuschko.gradle.nexus.NexusPlugin;
import com.bmuschko.gradle.nexus.NexusPluginExtension;
import com.github.benmanes.gradle.versions.VersionsPlugin;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import groovy.lang.Closure;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import nebula.plugin.info.InfoPlugin;
import net.saliman.gradle.plugin.cobertura.CoberturaExtension;
import net.saliman.gradle.plugin.cobertura.CoberturaPlugin;
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
import org.gradle.api.Action;
import org.gradle.api.JavaVersion;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.maven.MavenDeployer;
import org.gradle.api.artifacts.maven.MavenPom;
import org.gradle.api.artifacts.maven.MavenResolver;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.quality.FindBugsExtension;
import org.gradle.api.plugins.quality.FindBugsPlugin;
import org.gradle.api.tasks.Upload;
import org.gradle.api.tasks.javadoc.Javadoc;
import org.gradle.api.tasks.testing.Test;
import org.gradle.api.tasks.testing.logging.TestExceptionFormat;
import org.gradle.api.tasks.testing.logging.TestLogEvent;
import org.gradle.api.tasks.testing.logging.TestLoggingContainer;
import org.gradle.external.javadoc.StandardJavadocDocletOptions;
import org.gradle.util.ConfigureUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The standard module plugin.
*
* @author shevek
*/
public class StdModulePlugin implements Plugin {
private static final Logger LOG = LoggerFactory.getLogger(StdModulePlugin.class);
public static void configureJavadoc(@Nonnull final Project project, @Nonnull final Javadoc javadoc) {
final StdProjectExtension extension = project.getRootProject().getExtensions().getByType(StdProjectExtension.class);
final StandardJavadocDocletOptions javadocOptions = (StandardJavadocDocletOptions) javadoc.getOptions();
javadoc.doFirst(new Action() {
@Override
public void execute(Task t) {
if (!t.getProject().getGradle().getStartParameter().isOffline())
javadocOptions.setLinks(extension.javadocLinks);
javadocOptions.setLinkSource(extension.javadocLinkSource);
if (!extension.javadocGroups.isEmpty())
javadocOptions.setGroups(extension.javadocGroups);
if (JavaVersion.current().isJava8Compatible())
if (extension.javadocQuiet)
javadocOptions.addStringOption("Xdoclint:none", "-quiet");
}
});
}
@Override
public void apply(final Project project) {
// Root
project.getRootProject().getPlugins().apply(StdProjectPlugin.class);
// Extensions
// final StdProjectExtension rootExtension = project.getRootProject().getExtensions().getByType(StdProjectExtension.class);
final StdModuleExtension extension = project.getExtensions().create("stdmodule", StdModuleExtension.class, project);
// Convention
project.getPlugins().apply(JavaPlugin.class);
project.getPlugins().apply(InfoPlugin.class);
project.getPlugins().apply(VersionsPlugin.class);
JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class);
java.setSourceCompatibility(JavaVersion.VERSION_1_7);
project.getRepositories().add(project.getRepositories().mavenCentral());
project.getRepositories().add(project.getRepositories().jcenter());
project.getDependencies().add("testCompile", "junit:junit:4.12");
project.getDependencies().add("testCompile", "org.slf4j:slf4j-api:1.7.12");
project.getDependencies().add("testRuntime", "ch.qos.logback:logback-classic:1.1.3");
Javadoc javadoc = (Javadoc) project.getTasks().getByName(JavaPlugin.JAVADOC_TASK_NAME);
configureJavadoc(project, javadoc);
Test test = (Test) project.getTasks().getByName(JavaPlugin.TEST_TASK_NAME);
test.systemProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
test.systemProperty("org.apache.commons.logging.simplelog.defaultlog", "debug");
test.systemProperty("org.apache.commons.logging.diagnostics.dest", "STDERR");
test.systemProperty("org.slf4j.simpleLogger.logFile", "System.out");
test.systemProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug");
test.systemProperty("jna.nosys", "true");
final String testSystemPropertyPrefix = "test-sys-prop.";
for (Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy