Search in sources :

Example 16 with JavaPlugin

use of org.gradle.api.plugins.JavaPlugin in project spring-boot-data-geode by spring-projects.

the class MavenPublishConventionsPlugin 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();
    });
}
Also used : JavaPlugin(org.gradle.api.plugins.JavaPlugin) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension)

Example 17 with JavaPlugin

use of org.gradle.api.plugins.JavaPlugin in project spring-session by spring-projects.

the class ManagementConfigurationPlugin method apply.

@Override
public void apply(Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    configurations.create(MANAGEMENT_CONFIGURATION_NAME, (management) -> {
        management.setVisible(false);
        management.setCanBeConsumed(false);
        management.setCanBeResolved(false);
        PluginContainer plugins = project.getPlugins();
        plugins.withType(JavaPlugin.class, (javaPlugin) -> {
            configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
            configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
            configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
            configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
        });
        plugins.withType(JavaTestFixturesPlugin.class, (javaTestFixturesPlugin) -> {
            configurations.getByName("testFixturesCompileClasspath").extendsFrom(management);
            configurations.getByName("testFixturesRuntimeClasspath").extendsFrom(management);
        });
        plugins.withType(MavenPublishPlugin.class, (mavenPublish) -> {
            PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
            publishing.getPublications().withType(MavenPublication.class, (mavenPublication -> {
                mavenPublication.versionMapping((versions) -> versions.allVariants(versionMapping -> versionMapping.fromResolutionResult()));
            }));
        });
        plugins.withType(PropDepsPlugin.class, (propDepsPlugin -> {
            configurations.getByName("optional").extendsFrom(management);
            configurations.getByName("provided").extendsFrom(management);
        }));
    });
}
Also used : PublishingExtension(org.gradle.api.publish.PublishingExtension) Project(org.gradle.api.Project) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) MavenPublishPlugin(org.gradle.api.publish.maven.plugins.MavenPublishPlugin) JavaTestFixturesPlugin(org.gradle.api.plugins.JavaTestFixturesPlugin) PropDepsPlugin(org.springframework.gradle.propdeps.PropDepsPlugin) PluginContainer(org.gradle.api.plugins.PluginContainer) JavaPlugin(org.gradle.api.plugins.JavaPlugin) MavenPublication(org.gradle.api.publish.maven.MavenPublication) Plugin(org.gradle.api.Plugin) PluginContainer(org.gradle.api.plugins.PluginContainer) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) PublishingExtension(org.gradle.api.publish.PublishingExtension)

Example 18 with JavaPlugin

use of org.gradle.api.plugins.JavaPlugin in project native-build-tools by graalvm.

the class NativeImagePlugin method apply.

@Override
public void apply(Project project) {
    Provider<NativeImageService> nativeImageServiceProvider = NativeImageService.registerOn(project);
    logger = GraalVMLogger.of(project.getLogger());
    DefaultGraalVmExtension graalExtension = (DefaultGraalVmExtension) registerGraalVMExtension(project);
    graalExtension.getUseArgFile().convention(true);
    project.getPlugins().withType(JavaPlugin.class, javaPlugin -> configureJavaProject(project, nativeImageServiceProvider, graalExtension));
    project.afterEvaluate(p -> {
        Map<String, Provider<Boolean>> agents = graalExtension.getAgentProperties();
        graalExtension.getBinaries().all(options -> {
            AgentConfiguration agentConfiguration = options.getAgent();
            if (agentConfiguration.getInstrumentedTask().isPresent()) {
                configureAgent(p, agents, graalExtension.getToolchainDetection().map(b -> !b), options, getExecOperations(), getFileOperations());
            }
        });
    });
}
Also used : DefaultGraalVmExtension(org.graalvm.buildtools.gradle.internal.DefaultGraalVmExtension) GradleUtils(org.graalvm.buildtools.gradle.internal.GradleUtils) ConfigurableFileCollection(org.gradle.api.file.ConfigurableFileCollection) Arrays(java.util.Arrays) NativeImageExecutableLocator.graalvmHomeProvider(org.graalvm.buildtools.gradle.internal.NativeImageExecutableLocator.graalvmHomeProvider) BuildNativeImageTask(org.graalvm.buildtools.gradle.tasks.BuildNativeImageTask) URISyntaxException(java.net.URISyntaxException) ListProperty(org.gradle.api.provider.ListProperty) JavaPlugin(org.gradle.api.plugins.JavaPlugin) NamedDomainObjectContainer(org.gradle.api.NamedDomainObjectContainer) NativeConfigurations(org.graalvm.buildtools.gradle.internal.NativeConfigurations) ApplicationPlugin(org.gradle.api.plugins.ApplicationPlugin) OutputDirectory(org.gradle.api.tasks.OutputDirectory) Task(org.gradle.api.Task) Provider(org.gradle.api.provider.Provider) ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) TaskProvider(org.gradle.api.tasks.TaskProvider) NativeImageOptions(org.graalvm.buildtools.gradle.dsl.NativeImageOptions) Locale(java.util.Locale) Map(java.util.Map) DuplicatesStrategy(org.gradle.api.file.DuplicatesStrategy) ExtensionAware(org.gradle.api.plugins.ExtensionAware) GraalVMExtension(org.graalvm.buildtools.gradle.dsl.GraalVMExtension) URI(java.net.URI) Path(java.nio.file.Path) LogLevel(org.gradle.api.logging.LogLevel) Project(org.gradle.api.Project) SharedConstants(org.graalvm.buildtools.utils.SharedConstants) GenerateResourcesConfigFile(org.graalvm.buildtools.gradle.tasks.GenerateResourcesConfigFile) GraalVMLogger(org.graalvm.buildtools.gradle.internal.GraalVMLogger) Set(java.util.Set) JavaForkOptions(org.gradle.process.JavaForkOptions) GFileUtils(org.gradle.util.GFileUtils) Collectors(java.util.stream.Collectors) TaskContainer(org.gradle.api.tasks.TaskContainer) ArchiveOperations(org.gradle.api.file.ArchiveOperations) DefaultTestBinaryConfig(org.graalvm.buildtools.gradle.internal.DefaultTestBinaryConfig) AGENT_OUTPUT_FOLDER(org.graalvm.buildtools.utils.SharedConstants.AGENT_OUTPUT_FOLDER) JavaToolchainService(org.gradle.jvm.toolchain.JavaToolchainService) AgentConfiguration(org.graalvm.buildtools.gradle.dsl.AgentConfiguration) Callable(java.util.concurrent.Callable) AbstractArchiveTask(org.gradle.api.tasks.bundling.AbstractArchiveTask) FileCollection(org.gradle.api.file.FileCollection) CommandLineArgumentProvider(org.gradle.process.CommandLineArgumentProvider) SourceSet(org.gradle.api.tasks.SourceSet) Inject(javax.inject.Inject) Configuration(org.gradle.api.artifacts.Configuration) LifecycleBasePlugin(org.gradle.language.base.plugins.LifecycleBasePlugin) VersionInfo(org.graalvm.buildtools.VersionInfo) AttributeContainer(org.gradle.api.attributes.AttributeContainer) Attribute(org.gradle.api.attributes.Attribute) DirectoryProperty(org.gradle.api.file.DirectoryProperty) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) ProcessGeneratedGraalResourceFiles(org.graalvm.buildtools.gradle.internal.ProcessGeneratedGraalResourceFiles) Directory(org.gradle.api.file.Directory) JvmReachabilityMetadataRepositoryExtension(org.graalvm.buildtools.gradle.dsl.JvmReachabilityMetadataRepositoryExtension) Test(org.gradle.api.tasks.testing.Test) FileSystemLocation(org.gradle.api.file.FileSystemLocation) FileSystemOperations(org.gradle.api.file.FileSystemOperations) BaseNativeImageOptions(org.graalvm.buildtools.gradle.internal.BaseNativeImageOptions) Jar(org.gradle.api.tasks.bundling.Jar) AGENT_PROPERTY(org.graalvm.buildtools.utils.SharedConstants.AGENT_PROPERTY) Action(org.gradle.api.Action) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) AgentCommandLineProvider(org.graalvm.buildtools.gradle.internal.AgentCommandLineProvider) NativeRunTask(org.graalvm.buildtools.gradle.tasks.NativeRunTask) ExecOperations(org.gradle.process.ExecOperations) DeprecatedNativeImageOptions(org.graalvm.buildtools.gradle.internal.DeprecatedNativeImageOptions) JavaApplication(org.gradle.api.plugins.JavaApplication) File(java.io.File) Consumer(java.util.function.Consumer) ObjectFactory(org.gradle.api.model.ObjectFactory) GradleUtils.transitiveProjectArtifacts(org.graalvm.buildtools.gradle.internal.GradleUtils.transitiveProjectArtifacts) Property(org.gradle.api.provider.Property) DefaultGraalVmExtension(org.graalvm.buildtools.gradle.internal.DefaultGraalVmExtension) JavaExec(org.gradle.api.tasks.JavaExec) JvmReachabilityMetadataService(org.graalvm.buildtools.gradle.internal.JvmReachabilityMetadataService) Collections(java.util.Collections) Plugin(org.gradle.api.Plugin) AgentConfiguration(org.graalvm.buildtools.gradle.dsl.AgentConfiguration) NativeImageExecutableLocator.graalvmHomeProvider(org.graalvm.buildtools.gradle.internal.NativeImageExecutableLocator.graalvmHomeProvider) Provider(org.gradle.api.provider.Provider) TaskProvider(org.gradle.api.tasks.TaskProvider) CommandLineArgumentProvider(org.gradle.process.CommandLineArgumentProvider) AgentCommandLineProvider(org.graalvm.buildtools.gradle.internal.AgentCommandLineProvider)

Example 19 with JavaPlugin

use of org.gradle.api.plugins.JavaPlugin in project spring-security by spring-projects.

the class ManagementConfigurationPlugin method apply.

@Override
public void apply(Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    configurations.create(MANAGEMENT_CONFIGURATION_NAME, (management) -> {
        management.setVisible(false);
        management.setCanBeConsumed(false);
        management.setCanBeResolved(false);
        PluginContainer plugins = project.getPlugins();
        plugins.withType(JavaPlugin.class, (javaPlugin) -> {
            configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
            configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
            configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
            configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
        });
        plugins.withType(JavaTestFixturesPlugin.class, (javaTestFixturesPlugin) -> {
            configurations.getByName("testFixturesCompileClasspath").extendsFrom(management);
            configurations.getByName("testFixturesRuntimeClasspath").extendsFrom(management);
        });
        plugins.withType(MavenPublishPlugin.class, (mavenPublish) -> {
            PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
            publishing.getPublications().withType(MavenPublication.class, (mavenPublication -> {
                mavenPublication.versionMapping((versions) -> versions.allVariants(versionMapping -> versionMapping.fromResolutionResult()));
            }));
        });
        plugins.withType(PropDepsPlugin.class, (propDepsPlugin -> {
            configurations.getByName("optional").extendsFrom(management);
            configurations.getByName("provided").extendsFrom(management);
        }));
    });
}
Also used : PublishingExtension(org.gradle.api.publish.PublishingExtension) Project(org.gradle.api.Project) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) MavenPublishPlugin(org.gradle.api.publish.maven.plugins.MavenPublishPlugin) JavaTestFixturesPlugin(org.gradle.api.plugins.JavaTestFixturesPlugin) PropDepsPlugin(org.springframework.gradle.propdeps.PropDepsPlugin) PluginContainer(org.gradle.api.plugins.PluginContainer) JavaPlugin(org.gradle.api.plugins.JavaPlugin) MavenPublication(org.gradle.api.publish.maven.MavenPublication) Plugin(org.gradle.api.Plugin) PluginContainer(org.gradle.api.plugins.PluginContainer) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) PublishingExtension(org.gradle.api.publish.PublishingExtension)

Example 20 with JavaPlugin

use of org.gradle.api.plugins.JavaPlugin in project spring-security 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();
    });
}
Also used : JavaPlugin(org.gradle.api.plugins.JavaPlugin) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension)

Aggregations

JavaPlugin (org.gradle.api.plugins.JavaPlugin)27 Configuration (org.gradle.api.artifacts.Configuration)13 Project (org.gradle.api.Project)12 Plugin (org.gradle.api.Plugin)11 JavaPluginExtension (org.gradle.api.plugins.JavaPluginExtension)10 Action (org.gradle.api.Action)8 PublishingExtension (org.gradle.api.publish.PublishingExtension)8 MavenPublication (org.gradle.api.publish.maven.MavenPublication)8 SourceSet (org.gradle.api.tasks.SourceSet)8 File (java.io.File)7 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)7 PluginContainer (org.gradle.api.plugins.PluginContainer)7 MavenPublishPlugin (org.gradle.api.publish.maven.plugins.MavenPublishPlugin)7 JavaPluginConvention (org.gradle.api.plugins.JavaPluginConvention)6 Callable (java.util.concurrent.Callable)5 SourceSetContainer (org.gradle.api.tasks.SourceSetContainer)5 JavaTestFixturesPlugin (org.gradle.api.plugins.JavaTestFixturesPlugin)4 Test (org.gradle.api.tasks.testing.Test)4 Set (java.util.Set)3 BasePlugin (org.gradle.api.plugins.BasePlugin)3