-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5026b5
commit 5ae6d44
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!src/main/java/io/freefair/gradle/plugins/build |
42 changes: 42 additions & 0 deletions
42
buildSrc/src/main/java/io/freefair/gradle/plugins/build/ListPluginIds.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.freefair.gradle.plugins.build; | ||
|
||
import org.gradle.api.DefaultTask; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.file.RegularFileProperty; | ||
import org.gradle.api.tasks.CacheableTask; | ||
import org.gradle.api.tasks.OutputFile; | ||
import org.gradle.api.tasks.TaskAction; | ||
import org.gradle.plugin.devel.GradlePluginDevelopmentExtension; | ||
import org.gradle.plugin.devel.PluginDeclaration; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.StandardOpenOption; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
public abstract class ListPluginIds extends DefaultTask { | ||
|
||
@OutputFile | ||
public abstract RegularFileProperty getOutputFile(); | ||
|
||
@TaskAction | ||
public void listIds() throws IOException { | ||
List<String> ids = new ArrayList<>(); | ||
|
||
for (Project subproject : getProject().getRootProject().getAllprojects()) { | ||
|
||
GradlePluginDevelopmentExtension extension = subproject.getExtensions().findByType(GradlePluginDevelopmentExtension.class); | ||
|
||
if (extension != null) { | ||
for (PluginDeclaration plugin : extension.getPlugins()) { | ||
ids.add(plugin.getId()); | ||
} | ||
} | ||
} | ||
|
||
Files.write(getOutputFile().get().getAsFile().toPath(), ids, StandardCharsets.UTF_8); | ||
} | ||
} |