Skip to content

Commit

Permalink
convert
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzawa-san committed Jul 12, 2023
1 parent a4b7eee commit 763bd7b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.gradle.api.internal.PropertiesTransformer;
import org.gradle.api.plugins.ExtensionAware;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.Delete;
import org.gradle.api.tasks.SourceSet;
import org.gradle.internal.xml.XmlTransformer;
Expand Down Expand Up @@ -62,12 +62,12 @@ public void apply(final Project project) {
.withType(
JavaPlugin.class,
javaPlugin -> {
JavaPluginConvention javaConvention =
project.getConvention().getPlugin(JavaPluginConvention.class);
JavaPluginExtension javaExtension =
project.getExtensions().getByType(JavaPluginExtension.class);
SourceSet mainSourceSet =
javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
SourceSet testSourceSet =
javaConvention.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);
javaExtension.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);

configureEclipse(project, mainSourceSet, testSourceSet);
});
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/com/diffplug/gradle/eclipse/apt/AptPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
import org.gradle.api.internal.HasConvention;
import org.gradle.api.plugins.GroovyBasePlugin;
import org.gradle.api.plugins.JavaBasePlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.reflect.HasPublicType;
import org.gradle.api.reflect.TypeOf;
import org.gradle.api.tasks.GroovySourceDirectorySet;
import org.gradle.api.tasks.GroovySourceSet;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
Expand Down Expand Up @@ -62,9 +63,9 @@ public void apply(final Project project) {
.withType(
JavaBasePlugin.class,
javaBasePlugin -> {
final JavaPluginConvention javaConvention =
project.getConvention().getPlugin(JavaPluginConvention.class);
javaConvention
final JavaPluginExtension javaExtension =
project.getExtensions().getByType(JavaPluginExtension.class);
javaExtension
.getSourceSets()
.all(
sourceSet -> {
Expand All @@ -84,17 +85,15 @@ public void apply(final Project project) {
.withType(
GroovyBasePlugin.class,
groovyBasePlugin -> {
JavaPluginConvention javaConvention =
project.getConvention().getPlugin(JavaPluginConvention.class);
javaConvention
JavaPluginExtension javaExtension =
project.getExtensions().getByType(JavaPluginExtension.class);
javaExtension
.getSourceSets()
.all(
sourceSet -> {
SourceDirectorySet groovy =
((HasConvention) sourceSet)
.getConvention()
.getPlugin(GroovySourceSet.class)
.getGroovy();
sourceSet.getExtensions()
.getByType(GroovySourceDirectorySet.class);
configureCompileTaskForSourceSet(
project,
sourceSet,
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/com/diffplug/gradle/osgi/BndManifestPlugin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2022 DiffPlug
* Copyright (C) 2016-2023 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,6 @@
*/
package com.diffplug.gradle.osgi;


import aQute.bnd.osgi.Builder;
import aQute.bnd.osgi.Constants;
import com.diffplug.common.base.*;
Expand All @@ -38,7 +37,7 @@
import org.gradle.api.Task;
import org.gradle.api.java.archives.Attributes;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetOutput;
import org.gradle.api.tasks.bundling.Jar;
Expand Down Expand Up @@ -150,8 +149,8 @@ public void execute(Task unused) {
}

private static Path outputManifest(Jar jarTask) {
JavaPluginConvention javaConvention = jarTask.getProject().getConvention().getPlugin(JavaPluginConvention.class);
SourceSet main = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
JavaPluginExtension javaExtension = jarTask.getProject().getExtensions().getByType(JavaPluginExtension.class);
SourceSet main = javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
return main.getOutput().getResourcesDir().toPath().resolve("META-INF/MANIFEST.MF");
}

Expand Down Expand Up @@ -188,8 +187,8 @@ private static String takeBndAction(Project project, Jar jarTask, Throwing.Funct
builder.addClasspath(runtimeConfig);

// put the class files and resources into the jar
JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
SourceSetOutput main = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput();
JavaPluginExtension javaExtension = project.getExtensions().getByType(JavaPluginExtension.class);
SourceSetOutput main = javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput();
// delete empty folders so that bnd doesn't make Export-Package entries for them
Set<String> includeresource = new LinkedHashSet<>();
deleteEmptyFoldersIfExists(main.getResourcesDir());
Expand Down

0 comments on commit 763bd7b

Please sign in to comment.