use of org.gradle.api.plugins.JavaPlugin in project gradle by gradle.
the class EclipseWtpPlugin method configureEclipseWtpFacet.
private void configureEclipseWtpFacet(final Project project, final EclipseModel eclipseModel) {
TaskProvider<GenerateEclipseWtpFacet> task = project.getTasks().register(ECLIPSE_WTP_FACET_TASK_NAME, GenerateEclipseWtpFacet.class, eclipseModel.getWtp().getFacet());
task.configure(new Action<GenerateEclipseWtpFacet>() {
@Override
public void execute(final GenerateEclipseWtpFacet task) {
task.setDescription("Generates the Eclipse WTP facet settings file.");
task.setInputFile(project.file(".settings/org.eclipse.wst.common.project.facet.core.xml"));
task.setOutputFile(project.file(".settings/org.eclipse.wst.common.project.facet.core.xml"));
}
});
addWorker(task, ECLIPSE_WTP_FACET_TASK_NAME);
project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
@Override
public void execute(JavaPlugin javaPlugin) {
if (hasWarOrEarPlugin(project)) {
return;
}
((IConventionAware) eclipseModel.getWtp().getFacet()).getConventionMapping().map("facets", new Callable<List<Facet>>() {
@Override
public List<Facet> call() throws Exception {
return Lists.newArrayList(new Facet(Facet.FacetType.fixed, "jst.java", null), new Facet(Facet.FacetType.installed, "jst.utility", "1.0"), new Facet(Facet.FacetType.installed, "jst.java", toJavaFacetVersion(project.getExtensions().getByType(JavaPluginExtension.class).getSourceCompatibility())));
}
});
}
});
project.getPlugins().withType(WarPlugin.class, new Action<WarPlugin>() {
@Override
public void execute(WarPlugin warPlugin) {
((IConventionAware) eclipseModel.getWtp().getFacet()).getConventionMapping().map("facets", new Callable<List<Facet>>() {
@Override
public List<Facet> call() throws Exception {
return Lists.newArrayList(new Facet(Facet.FacetType.fixed, "jst.java", null), new Facet(Facet.FacetType.fixed, "jst.web", null), new Facet(Facet.FacetType.installed, "jst.web", "2.4"), new Facet(Facet.FacetType.installed, "jst.java", toJavaFacetVersion(project.getExtensions().getByType(JavaPluginExtension.class).getSourceCompatibility())));
}
});
}
});
project.getPlugins().withType(EarPlugin.class, new Action<EarPlugin>() {
@Override
public void execute(EarPlugin earPlugin) {
((IConventionAware) eclipseModel.getWtp().getFacet()).getConventionMapping().map("facets", new Callable<List<Facet>>() {
@Override
public List<Facet> call() throws Exception {
return Lists.newArrayList(new Facet(Facet.FacetType.fixed, "jst.ear", null), new Facet(Facet.FacetType.installed, "jst.ear", "5.0"));
}
});
}
});
}
use of org.gradle.api.plugins.JavaPlugin in project gradle by gradle.
the class EarPlugin method setupEarTask.
private void setupEarTask(final Project project, EarPluginConvention convention, PluginContainer plugins) {
TaskProvider<Ear> ear = project.getTasks().register(EAR_TASK_NAME, Ear.class, new Action<Ear>() {
@Override
public void execute(Ear ear) {
ear.setDescription("Generates a ear archive with all the modules, the application descriptor and the libraries.");
ear.setGroup(BasePlugin.BUILD_GROUP);
ear.getGenerateDeploymentDescriptor().convention(convention.getGenerateDeploymentDescriptor());
plugins.withType(JavaPlugin.class, javaPlugin -> {
final JavaPluginExtension javaPluginExtension = project.getExtensions().findByType(JavaPluginExtension.class);
SourceSet sourceSet = mainSourceSetOf(javaPluginExtension);
sourceSet.getResources().srcDir(ear.getAppDirectory());
});
}
});
DeploymentDescriptor deploymentDescriptor = convention.getDeploymentDescriptor();
if (deploymentDescriptor != null) {
if (deploymentDescriptor.getDisplayName() == null) {
deploymentDescriptor.setDisplayName(project.getName());
}
if (deploymentDescriptor.getDescription() == null) {
deploymentDescriptor.setDescription(project.getDescription());
}
}
project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(new LazyPublishArtifact(ear, ((ProjectInternal) project).getFileResolver()));
project.getTasks().withType(Ear.class).configureEach(new Action<Ear>() {
@Override
public void execute(Ear task) {
}
});
}
use of org.gradle.api.plugins.JavaPlugin in project gradle-apt-plugin by tbroyer.
the class AptPlugin25to211 method ensureCompileOnlyConfiguration.
@Override
protected void ensureCompileOnlyConfiguration(final Project project, final SourceSet sourceSet, AptPlugin.AptSourceSetConvention convention) {
Configuration configuration = project.getConfigurations().create(convention.getCompileOnlyConfigurationName());
configuration.setVisible(false);
configuration.setDescription("Compile-only classpath for " + sourceSet.getName());
configuration.extendsFrom(project.getConfigurations().findByName(sourceSet.getCompileConfigurationName()));
sourceSet.setCompileClasspath(configuration);
if (SourceSet.TEST_SOURCE_SET_NAME.equals(sourceSet.getName())) {
final Configuration conf = configuration;
project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
@Override
public void execute(JavaPlugin javaPlugin) {
sourceSet.setCompileClasspath(project.files(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput(), conf));
}
});
}
}
use of org.gradle.api.plugins.JavaPlugin in project spring-boot-data-geode by spring-projects.
the class MavenPublishingConventionsPlugin method customizeJavaPlugin.
private void customizeJavaPlugin(Project project) {
project.getPlugins().withType(JavaPlugin.class).all(javaPlugin -> {
JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
extension.withJavadocJar();
extension.withSourcesJar();
});
}
use of org.gradle.api.plugins.JavaPlugin in project spring-session by spring-projects.
the class MavenPublishingConventionsPlugin method customizeJavaPlugin.
private void customizeJavaPlugin(Project project) {
project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
extension.withJavadocJar();
extension.withSourcesJar();
});
}
Aggregations