Skip to content

Commit

Permalink
Fix Gradle 9 deprecations (#850)
Browse files Browse the repository at this point in the history
* Remove use of getConvention for application plugin

* Remove redundant configuration

The way the mainClassName is set is deprecated in Gradle 9, and this code was
only required for older releases of the shadow plugin.
  • Loading branch information
melix authored Oct 17, 2023
1 parent 7e17b50 commit 404d20b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.gradle.api.java.archives.Attributes;
import org.gradle.api.logging.Logger;
import org.gradle.api.plugins.ApplicationPlugin;
import org.gradle.api.plugins.ApplicationPluginConvention;
import org.gradle.api.plugins.JavaApplication;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.provider.Provider;
Expand Down Expand Up @@ -183,7 +182,7 @@ private void registerCreateSamplesTasks(Project project, Configuration optimizer
private void registerOptimizedDistribution(Project project,
TaskProvider<Jar> optimizedJar) {
DistributionContainer distributions = project.getExtensions().getByType(DistributionContainer.class);
ApplicationPluginConvention appConvention = project.getConvention().getPlugin(ApplicationPluginConvention.class);
JavaApplication appConvention = project.getExtensions().getByType(JavaApplication.class);
ConfigurableFileCollection classpath = project.getObjects().fileCollection();
classpath.from(optimizedJar);
classpath.from(project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.SourceDirectorySet;
import org.gradle.api.plugins.ApplicationPlugin;
import org.gradle.api.plugins.JavaApplication;
import org.gradle.api.plugins.PluginManager;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.JavaExec;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
Expand Down Expand Up @@ -191,17 +189,7 @@ private void configureMicronautRuntime(Project project) {
if (micronautRuntime == MicronautRuntime.GOOGLE_FUNCTION) {
configureGoogleCloudFunctionRuntime(project, p, dependencyHandler);
}
ShadowPluginSupport.withShadowPlugin(project, () -> {
JavaApplication javaApplication = project
.getExtensions().findByType(JavaApplication.class);
if (javaApplication != null) {
Property<String> mainClass = javaApplication.getMainClass();
if (mainClass.isPresent()) {
project.setProperty("mainClassName", mainClass.get());
}
}
ShadowPluginSupport.mergeServiceFiles(project);
});
ShadowPluginSupport.withShadowPlugin(project, () -> ShadowPluginSupport.mergeServiceFiles(project));

});
}
Expand Down

0 comments on commit 404d20b

Please sign in to comment.