Skip to content

Commit

Permalink
aspectj: fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgrefer committed Aug 28, 2023
1 parent b84c666 commit 4096e9e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ public void apply(Project project) {
project.getPlugins().apply(AspectJBasePlugin.class);
project.getPlugins().apply(JavaBasePlugin.class);

JavaPluginExtension plugin = project.getExtensions().getByType(JavaPluginExtension.class);
JavaPluginExtension javaExtension = project.getExtensions().getByType(JavaPluginExtension.class);

JavaToolchainService service = project.getExtensions().getByType(JavaToolchainService.class);
defaultLauncher = service.launcherFor(plugin.getToolchain());
defaultLauncher = service.launcherFor(javaExtension.getToolchain());

plugin.getSourceSets().all(this::configureSourceSet);
javaExtension.getSourceSets().all(this::configureSourceSet);

project.getPlugins().withType(JavaPlugin.class, javaPlugin -> {

SourceSet main = plugin.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
SourceSet test = plugin.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);
SourceSet main = javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
SourceSet test = javaExtension.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);

Configuration aspectpath = project.getConfigurations().getByName(WeavingSourceSet.getAspectConfigurationName(main));
Configuration testAspectpath = project.getConfigurations().getByName(WeavingSourceSet.getAspectConfigurationName(test));
Expand All @@ -66,6 +66,9 @@ public void apply(Project project) {
}

private void configureSourceSet(SourceSet sourceSet) {
sourceSet.getExtensions().add(WeavingSourceSet.IN_PATH_EXTENSION_NAME, project.getObjects().fileCollection());
sourceSet.getExtensions().add(WeavingSourceSet.ASPECT_PATH_EXTENSION_NAME, project.getObjects().fileCollection());

DefaultAspectjSourceSet aspectjSourceSet = new DefaultAspectjSourceSet(project.getObjects(), sourceSet);
new DslObject(sourceSet).getConvention().getPlugins().put("aspectj", aspectjSourceSet);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.freefair.gradle.plugins.aspectj;

import io.freefair.gradle.plugins.aspectj.internal.DefaultWeavingSourceSet;
import org.gradle.api.NonNullApi;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.file.FileCollection;
import org.gradle.api.internal.plugins.DslObject;
import org.gradle.api.internal.tasks.compile.HasCompileOptions;
import org.gradle.api.plugins.GroovyPlugin;
import org.gradle.api.plugins.JavaBasePlugin;
Expand Down Expand Up @@ -62,8 +60,8 @@ public void apply(Project project) {
}

private void configureSourceSetDefaults(SourceSet sourceSet) {
DefaultWeavingSourceSet weavingSourceSet = new DefaultWeavingSourceSet(sourceSet, project.getObjects());
new DslObject(sourceSet).getConvention().add("aspectj", weavingSourceSet);
sourceSet.getExtensions().add(WeavingSourceSet.IN_PATH_EXTENSION_NAME, project.getObjects().fileCollection());
sourceSet.getExtensions().add(WeavingSourceSet.ASPECT_PATH_EXTENSION_NAME, project.getObjects().fileCollection());

Configuration aspectpath = project.getConfigurations().create(WeavingSourceSet.getAspectConfigurationName(sourceSet));
WeavingSourceSet.getAspectPath(sourceSet).from(aspectpath);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package io.freefair.gradle.plugins.aspectj;

import groovy.lang.Closure;
import org.gradle.api.Action;
import org.gradle.api.file.SourceDirectorySet;
import org.gradle.api.tasks.SourceSet;

import javax.annotation.Nullable;

/**
* @see org.gradle.api.tasks.GroovySourceSet
* @see org.gradle.api.tasks.ScalaSourceSet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.freefair.gradle.plugins.aspectj;

import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileCollection;
import org.gradle.api.tasks.SourceSet;

public interface WeavingSourceSet {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
* @see org.gradle.api.internal.tasks.DefaultGroovySourceSet
*/
@Getter
public class DefaultAspectjSourceSet extends DefaultWeavingSourceSet implements AspectjSourceSet, HasPublicType {
public class DefaultAspectjSourceSet implements AspectjSourceSet, HasPublicType {

public DefaultAspectjSourceSet(ObjectFactory objectFactory, SourceSet sourceSet) {
super(sourceSet, objectFactory);

String name = sourceSet.getName();
String displayName = ((DefaultSourceSet) sourceSet).getDisplayName();

Expand Down

This file was deleted.

0 comments on commit 4096e9e

Please sign in to comment.