Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove animalsniffer plugin automatically #456

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public class PluginUtils {
PLUGINS.put("nebula.publish-verification", new PluginReference("nebulaPublishVerification"));
PLUGINS.put("signing", new PluginReference(Collections.singleton("signing"), "SigningPlugin", null));
PLUGINS.put(SEMANTIC_BUILD_VERSIONING, new PluginReference("preRelease"));
PLUGINS.put("ru.vyarus.animalsniffer", new PluginReference(Stream.of("animalsniffer").collect(
Collectors.toSet()), "",
Stream.of("org.codehaus.mojo.signature:", "ru.vyarus:gradle-animalsniffer-plugin")
.collect(Collectors.toSet())));
}

/**
Expand Down Expand Up @@ -141,7 +145,7 @@ public static DokkaVersion parseVersion(String version)
public static void pluginRemoval(Logger logger, File target, Set<String> plugins)
throws ManipulationException {

if (plugins == null || plugins.size() == 0) {
if (plugins == null || plugins.isEmpty()) {
return;
} else if (plugins.contains("ALL")) {
// Shortcut to represent removing any/all of the supported plugins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,46 @@ public void testRemoval17()
assertFalse(result.contains("<DependencyUpdatesTask>"));
}

@Test
public void testRemoval18()
throws IOException, ManipulationException {

File target = folder.newFile("build.gradle");
org.apache.commons.io.FileUtils.writeStringToFile(target,
"buildscript {\n" +
" repositories {\n" +
" jcenter()\n" +
" mavenCentral()\n" +
" maven {\n" +
" url \"https://plugins.gradle.org/m2/\"\n" +
" }\n" +
" }\n" +
" dependencies {\n" +
" classpath \"ru.vyarus:gradle-animalsniffer-plugin:1.2.0\"\n" +
" }\n" +
"}\n" +
"\n" +
"apply plugin: \"ru.vyarus.animalsniffer\"\n" +
"\n" +
"dependencies {\n" +
" signature \"org.codehaus.mojo.signature:java16:1.1@signature\"\n" +
"}\n" +
"\n" +
"animalsniffer {\n" +
" annotation = \"io.reactivex.internal.util.SuppressAnimalSniffer\"\n" +
"}",
Charset.defaultCharset());

HashSet<String> plugins = new LinkedHashSet<>();
plugins.add("ALL");
PluginUtils.pluginRemoval(logger, target.getParentFile(), plugins);

String result = FileUtils.readFileToString(target, Charset.defaultCharset());

assertFalse(result.contains("signature"));
assertFalse(result.contains("animalsniffer"));
}

@Test
public void testCheckForSemanticPlugin1()
throws IOException, ManipulationException {
Expand Down
Loading