Skip to content

Commit

Permalink
fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgrefer committed Aug 27, 2023
1 parent f915332 commit c35440e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AspectJRuntime(Project project) {
public FileCollection inferAspectjClasspath(final FileCollection classpath) {
// alternatively, we could return project.getLayout().files(Runnable)
// would differ in at least the following ways: 1. live 2. no autowiring
return new LazilyInitializedFileCollection() {
return new LazilyInitializedFileCollection(project.getTaskDependencyFactory()) {

@Override
public String getDisplayName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
import io.freefair.gradle.plugins.aspectj.AspectjSourceDirectorySet;
import org.gradle.api.file.SourceDirectorySet;
import org.gradle.api.internal.file.DefaultSourceDirectorySet;
import org.gradle.api.internal.tasks.TaskDependencyFactory;

import javax.inject.Inject;


/**
* @author Lars Grefer
* @see org.gradle.api.internal.tasks.DefaultGroovySourceDirectorySet
* @see org.gradle.api.internal.tasks.DefaultScalaSourceDirectorySet
*/
public class DefaultAspectjSourceDirectorySet extends DefaultSourceDirectorySet implements AspectjSourceDirectorySet {
public DefaultAspectjSourceDirectorySet(SourceDirectorySet sourceSet) {
super(sourceSet);
public abstract class DefaultAspectjSourceDirectorySet extends DefaultSourceDirectorySet implements AspectjSourceDirectorySet {
@Inject
public DefaultAspectjSourceDirectorySet(SourceDirectorySet sourceDirectorySet, TaskDependencyFactory taskDependencyFactory) {
super(sourceDirectorySet, taskDependencyFactory);
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
package io.freefair.gradle.plugins.aspectj.internal;

import groovy.lang.Closure;
import io.freefair.gradle.plugins.aspectj.AspectjSourceDirectorySet;
import io.freefair.gradle.plugins.aspectj.AspectjSourceSet;
import io.freefair.gradle.plugins.aspectj.WeavingSourceSet;
import lombok.Getter;
import org.gradle.api.Action;
import org.gradle.api.file.SourceDirectorySet;
import org.gradle.api.internal.tasks.DefaultSourceSet;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.reflect.HasPublicType;
import org.gradle.api.reflect.TypeOf;
import org.gradle.api.tasks.SourceSet;
import org.gradle.internal.deprecation.DeprecationLogger;
import org.gradle.util.ConfigureUtil;

import javax.annotation.Nullable;

/**
* @see org.gradle.api.internal.tasks.DefaultGroovySourceSet
Expand All @@ -29,7 +22,7 @@ public DefaultAspectjSourceSet(ObjectFactory objectFactory, SourceSet sourceSet)
String name = sourceSet.getName();
String displayName = ((DefaultSourceSet) sourceSet).getDisplayName();

AspectjSourceDirectorySet aspectj = new DefaultAspectjSourceDirectorySet(objectFactory.sourceDirectorySet("aspectj", displayName + " AspectJ source"));
AspectjSourceDirectorySet aspectj = createAspectjSourceDirectorySet(name, displayName, objectFactory);
aspectj.getFilter().include("**/*.java", "**/*.aj");
SourceDirectorySet allAspectj = objectFactory.sourceDirectorySet("all" + name, displayName + " AspectJ source");
allAspectj.source(aspectj);
Expand All @@ -39,6 +32,12 @@ public DefaultAspectjSourceSet(ObjectFactory objectFactory, SourceSet sourceSet)
sourceSet.getExtensions().add("allAspectj", allAspectj);
}

private static AspectjSourceDirectorySet createAspectjSourceDirectorySet(String name, String displayName, ObjectFactory objectFactory) {
AspectjSourceDirectorySet aspectjSourceDirectorySet = objectFactory.newInstance(DefaultAspectjSourceDirectorySet.class, objectFactory.sourceDirectorySet(name, displayName + " AspectJ source"));
aspectjSourceDirectorySet.getFilter().include("**/*.java", "**/*.aj");
return aspectjSourceDirectorySet;
}

@Override
public TypeOf<?> getPublicType() {
return TypeOf.typeOf(AspectjSourceSet.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
@Data
public class DefaultWeavingSourceSet implements WeavingSourceSet, HasPublicType {

private final SourceSet sourceSet;

public DefaultWeavingSourceSet(SourceSet sourceSet, ObjectFactory objectFactory) {
this.sourceSet = sourceSet;

sourceSet.getExtensions().add("aspectPath", objectFactory.fileCollection());
sourceSet.getExtensions().add("inPath", objectFactory.fileCollection());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.CopySpec;
import org.gradle.api.file.Directory;
import org.gradle.api.file.FileTree;
import org.gradle.api.internal.file.copy.CopySpecInternal;
import org.gradle.api.plugins.WarPlugin;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.Sync;
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
import org.gradle.api.tasks.bundling.War;
Expand Down Expand Up @@ -122,10 +124,11 @@ private void configureOverlay(WarOverlay overlay, ExternalDependency dependency)
private void configureOverlay(WarOverlay overlay, Callable<FileTree> warTree) {
War warTask = overlay.getWarTask();

String capitalizedWarTaskName = StringGroovyMethods.capitalize((CharSequence) warTask.getName());
String capitalizedOverlayName = StringGroovyMethods.capitalize((CharSequence) overlay.getName());
String capitalizedWarTaskName = StringGroovyMethods.capitalize(warTask.getName());
String capitalizedOverlayName = StringGroovyMethods.capitalize(overlay.getName());

Provider<Directory> destinationDir = project.getLayout().getBuildDirectory().dir(String.format("overlays/%s/%s", warTask.getName(), overlay.getName()));

File destinationDir = new File(project.getBuildDir(), String.format("overlays/%s/%s", warTask.getName(), overlay.getName()));
Action<CopySpec> extractOverlay = copySpec -> {
copySpec.into(destinationDir);
copySpec.from(warTree);
Expand All @@ -137,13 +140,13 @@ private void configureOverlay(WarOverlay overlay, Callable<FileTree> warTree) {

if (overlay.isEnableCompilation()) {

if (!destinationDir.exists() || isEmpty(destinationDir)) {
if (!destinationDir.get().getAsFile().exists() || isEmpty(destinationDir.get().getAsFile())) {
project.sync(extractOverlay);
}

project.getTasks().getByName(CLEAN_TASK_NAME).finalizedBy(extractOverlayTask);

ConfigurableFileCollection classes = project.files(new File(destinationDir, "WEB-INF/classes"))
ConfigurableFileCollection classes = project.files(destinationDir.get().dir("WEB-INF/classes"))
.builtBy(extractOverlayTask);

project.getDependencies().add(getClasspathConfigurationName(overlay), classes);
Expand Down

0 comments on commit c35440e

Please sign in to comment.