本文整理汇总了Java中org.gradle.api.plugins.JavaBasePlugin类的典型用法代码示例。如果您正苦于以下问题:Java JavaBasePlugin类的具体用法?Java JavaBasePlugin怎么用?Java JavaBasePlugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaBasePlugin类属于org.gradle.api.plugins包,在下文中一共展示了JavaBasePlugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
public void apply(final Project project) {
project.getPluginManager().apply(JavaBasePlugin.class);
final OsgiPluginConvention osgiConvention = new OsgiPluginConvention((ProjectInternal) project);
project.getConvention().getPlugins().put("osgi", osgiConvention);
project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
@Override
public void execute(JavaPlugin javaPlugin) {
OsgiManifest osgiManifest = osgiConvention.osgiManifest();
osgiManifest.setClassesDir(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main").getOutput().getClassesDir());
osgiManifest.setClasspath(project.getConfigurations().getByName("runtime"));
Jar jarTask = (Jar) project.getTasks().getByName("jar");
jarTask.setManifest(osgiManifest);
}
});
}
示例2: configureCheckstyleTasks
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
/**
* Create Checkstyle tasks
*
* @param tasks Task container
* @param checkstyleConfig Checkstyle configuration
* @param sources Source sets
* @param files
* @param context
*/
@Finalize
public void configureCheckstyleTasks(ModelMap<Checkstyle> tasks, CheckstyleConfig checkstyleConfig,
ProjectSourceSet sources, FileOperations files, ProjectContext context) {
for (JavaSourceSet source : sources.withType(JavaSourceSet.class)) {
String taskName = getCheckstyleTaskName(source);
if (!checkstyleConfig.getIgnoreSourceSets().contains(source.getParentName())) {
tasks.named(taskName, t -> {
File checkstyleConfigFile = getCheckstyleConfigFile(source.getParentName(), files);
t.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
t.setConfigFile(checkstyleConfigFile);
if (checkstyleConfigFile.getParentFile() != null) {
t.setConfigDir(context.provider(() -> checkstyleConfigFile.getParentFile()));
}
t.dependsOn(getUpdateConfigTaskName(source));
});
}
}
}
示例3: apply
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
@Override
public void apply(Project project) {
project.getExtensions().create(SWARM_EXTENSION, SwarmExtension.class, project);
project.afterEvaluate(__ -> {
final TaskContainer tasks = project.getTasks();
final PackageTask packageTask = tasks.create(WILDFLY_SWARM_PACKAGE_TASK_NAME, PackageTask.class);
final Jar archiveTask = getArchiveTask(project);
if (archiveTask == null) {
throw new GradleException("No suitable Archive-Task found to include in Swarm Uber-JAR.");
}
packageTask.jarTask(archiveTask).dependsOn(archiveTask);
tasks.getByName(JavaBasePlugin.BUILD_TASK_NAME).dependsOn(packageTask);
});
}
示例4: apply
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
@Override
public void apply(Project project) {
project.getPlugins().apply("idea");
// everything below this is only at the (top-level) "Project" level, not the "Module" level
if (project == project.getRootProject()) {
LOG.info("Configuring the 'idea' plugin");
codeStyleExtension(project);
val ideaProject = ideaProject(project);
ideaProject.setVcs("Git");
ideaProject.getIpr().withXml(xmlProvider -> customizeProjectXml(project, xmlProvider));
project.getPlugins().withType(JavaBasePlugin.class, plugin -> configLanguageVersion(project));
}
}
示例5: apply
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
public void apply(Project project) {
project.getPluginManager().apply(JavaBasePlugin.class);
configureConfigurations(project);
ScalaRuntime scalaRuntime = configureScalaRuntimeExtension(project);
configureCompileDefaults(project, scalaRuntime);
configureSourceSetDefaults(project, sourceDirectorySetFactory);
configureScaladoc(project, scalaRuntime);
}
示例6: configureSourceSetDefaults
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
private static void configureSourceSetDefaults(final Project project, final SourceDirectorySetFactory sourceDirectorySetFactory) {
final JavaBasePlugin javaPlugin = project.getPlugins().getPlugin(JavaBasePlugin.class);
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
@Override
public void execute(final SourceSet sourceSet) {
String displayName = (String) InvokerHelper.invokeMethod(sourceSet, "getDisplayName", null);
Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
DefaultScalaSourceSet scalaSourceSet = new DefaultScalaSourceSet(displayName, sourceDirectorySetFactory);
sourceSetConvention.getPlugins().put("scala", scalaSourceSet);
final SourceDirectorySet scalaDirectorySet = scalaSourceSet.getScala();
scalaDirectorySet.srcDir(new Callable<File>() {
@Override
public File call() throws Exception {
return project.file("src/" + sourceSet.getName() + "/scala");
}
});
sourceSet.getAllJava().source(scalaDirectorySet);
sourceSet.getAllSource().source(scalaDirectorySet);
sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
@Override
public boolean isSatisfiedBy(FileTreeElement element) {
return scalaDirectorySet.contains(element.getFile());
}
});
configureScalaCompile(project, javaPlugin, sourceSet);
}
});
}
示例7: configureScalaCompile
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
private static void configureScalaCompile(final Project project, JavaBasePlugin javaPlugin, final SourceSet sourceSet) {
String taskName = sourceSet.getCompileTaskName("scala");
final ScalaCompile scalaCompile = project.getTasks().create(taskName, ScalaCompile.class);
scalaCompile.dependsOn(sourceSet.getCompileJavaTaskName());
javaPlugin.configureForSourceSet(sourceSet, scalaCompile);
Convention scalaConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
ScalaSourceSet scalaSourceSet = scalaConvention.findPlugin(ScalaSourceSet.class);
scalaCompile.setDescription("Compiles the " + scalaSourceSet.getScala() + ".");
scalaCompile.setSource(scalaSourceSet.getScala());
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(taskName);
// cannot use convention mapping because the resulting object won't be serializable
// cannot compute at task execution time because we need association with source set
project.getGradle().addBuildListener(new BuildAdapter() {
@Override
public void projectsEvaluated(Gradle gradle) {
IncrementalCompileOptions incrementalOptions = scalaCompile.getScalaCompileOptions().getIncrementalOptions();
if (incrementalOptions.getAnalysisFile() == null) {
String analysisFilePath = project.getBuildDir().getPath() + "/tmp/scala/compilerAnalysis/" + scalaCompile.getName() + ".analysis";
incrementalOptions.setAnalysisFile(new File(analysisFilePath));
}
if (incrementalOptions.getPublishedCode() == null) {
Jar jarTask = (Jar) project.getTasks().findByName(sourceSet.getJarTaskName());
incrementalOptions.setPublishedCode(jarTask == null ? null : jarTask.getArchivePath());
}
}
});
}
示例8: configureTaskPropertiesValidation
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
private void configureTaskPropertiesValidation(Project project) {
ValidateTaskProperties validator = project.getTasks().create(VALIDATE_TASK_PROPERTIES_TASK_NAME, ValidateTaskProperties.class);
File reportsDir = new File(project.getBuildDir(), "reports");
File validatorReportsDir = new File(reportsDir, "task-properties");
validator.setOutputFile(new File(validatorReportsDir, "report.txt"));
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
validator.setClasspath(mainSourceSet.getCompileClasspath());
validator.setClassesDir(mainSourceSet.getOutput().getClassesDir());
validator.dependsOn(mainSourceSet.getOutput());
project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(validator);
}
示例9: apply
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
@Override
public void apply(Project project) {
GeneratePluginExtension generatePluginExtension = project.getExtensions().create(EXTENSION_NAME,
GeneratePluginExtension.class, project);
GenerateTask generateTask = project.getTasks().create(TASK_NAME, GenerateTask.class);
generateTask.setGroup(BasePlugin.BUILD_GROUP);
generateTask.setDescription("Generates DDL scripts based on JPA model.");
generateTask.setExtension(generatePluginExtension);
generateTask.dependsOn(JavaBasePlugin.BUILD_TASK_NAME);
project.afterEvaluate(evaluatedProject -> {
fillDefaults(evaluatedProject, generatePluginExtension);
SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
Set<File> paths;
if (sourceSets != null) {
UnionFileCollection mainClasspath = (UnionFileCollection) sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
paths = mainClasspath.getSources()
.stream()
.filter(fileCollection -> fileCollection instanceof DefaultSourceSetOutput)
.map(DefaultSourceSetOutput.class::cast)
.flatMap(fileCollection -> fileCollection.getClassesDirs().getFiles().stream())
.collect(Collectors.toSet());
} else {
paths = new HashSet<>();
}
generateTask.setOutputClassesDirs(paths);
});
}
示例10: createSiteTask
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
private SiteGenerate createSiteTask(Project project, SitePluginExtension sitePluginExtension) {
SiteGenerate generateSiteTask = project.getTasks().create(GENERATE_SITE_TASK_NAME, SiteGenerate.class);
generateSiteTask.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
generateSiteTask.setDescription("Generates a web page containing information about the project.");
generateSiteTask.getOutputDir().set(sitePluginExtension.getOutputDir());
generateSiteTask.getCustomData().setWebsiteUrl(sitePluginExtension.getWebsiteUrl());
generateSiteTask.getCustomData().setVcsUrl(sitePluginExtension.getVcsUrl());
return generateSiteTask;
}
示例11: createIntegrationTask
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
/**
* Create integration test task
*
* @param tasks Task model
*/
@Mutate
public void createIntegrationTask(ModelMap<Test> tasks) {
tasks.create(INTEGRATION_SOURCE_SET_NAME, t -> {
t.setDescription("Runs the integration tests");
t.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
});
}
示例12: configureCheckTask
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
/**
* Configure the check task
*
* @param tasks Tasks
*/
@Mutate
public void configureCheckTask(ModelMap<Task> tasks) {
tasks.named(JavaBasePlugin.CHECK_TASK_NAME, t -> {
t.dependsOn(INTEGRATION_TASK_NAME);
});
}
示例13: createCheckstyleTask
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
/**
* Create Checkstyle task
*
* @param tasks Task container
* @param checkstyleConfig Checkstyle configuration
* @param sources Project sources to run checkstyle on
*/
@Mutate
public void createCheckstyleTask(ModelMap<Task> tasks, CheckstyleConfig checkstyleConfig,
ProjectSourceSet sources) {
tasks.create("checkstyle", t -> {
t.setDescription("Run Checkstyle on all source sets");
t.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
for (JavaSourceSet source : sources.withType(JavaSourceSet.class)) {
if (!checkstyleConfig.getIgnoreSourceSets().contains(source.getParentName())) {
t.dependsOn(getCheckstyleTaskName(source));
}
}
});
}
示例14: apply
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
@Override
public void apply(Project project) {
super.apply(project);
allJavadocTask = project.getTasks().create("javadoc", ajdTasks -> {
ajdTasks.setDescription("Generate Javadoc for all variants");
ajdTasks.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
});
}
示例15: configureForVariants
import org.gradle.api.plugins.JavaBasePlugin; //导入依赖的package包/类
private void configureForVariants(DomainObjectSet<? extends BaseVariant> variants) {
variants.all(sourceSet -> {
Task task = project.getTasks().create(getTaskName(sourceSet, getTaskBaseName(), null), getCastedTaskType());
task.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
configureForVariant(sourceSet, (T)task);
});
}