|
16 | 16 |
|
17 | 17 | package org.springframework.boot.build.classpath;
|
18 | 18 |
|
| 19 | +import java.util.Set; |
19 | 20 | import java.util.TreeSet;
|
20 | 21 | import java.util.stream.Collectors;
|
21 | 22 |
|
|
35 | 36 | */
|
36 | 37 | public class CheckClasspathForProhibitedDependencies extends DefaultTask {
|
37 | 38 |
|
| 39 | + private static final Set<String> PROHIBITED_GROUPS = Set.of("org.codehaus.groovy", "org.eclipse.jetty.toolchain", |
| 40 | + "commons-logging", "org.apache.geronimo.specs", "com.sun.activation"); |
| 41 | + |
| 42 | + private static final Set<String> PERMITTED_JAVAX_GROUPS = Set.of("javax.batch", "javax.cache", "javax.money"); |
| 43 | + |
38 | 44 | private Configuration classpath;
|
39 | 45 |
|
40 | 46 | public CheckClasspathForProhibitedDependencies() {
|
@@ -69,29 +75,20 @@ public void checkForProhibitedDependencies() {
|
69 | 75 | }
|
70 | 76 |
|
71 | 77 | private boolean prohibited(ModuleVersionIdentifier id) {
|
72 |
| - String group = id.getGroup(); |
73 |
| - switch (group) { |
74 |
| - case "javax.batch", "javax.cache", "javax.money" -> { |
75 |
| - return false; |
76 |
| - } |
77 |
| - case "commons-logging", "org.codehaus.groovy", "org.eclipse.jetty.toolchain", |
78 |
| - "org.apache.geronimo.specs" -> { |
79 |
| - return true; |
80 |
| - } |
81 |
| - } |
82 |
| - if (group.startsWith("javax")) { |
83 |
| - return true; |
84 |
| - } |
85 |
| - if (group.equals("org.slf4j") && id.getName().equals("jcl-over-slf4j")) { |
86 |
| - return true; |
87 |
| - } |
88 |
| - if (group.startsWith("org.jboss.spec")) { |
89 |
| - return true; |
90 |
| - } |
91 |
| - if (group.equals("org.apache.geronimo.specs")) { |
92 |
| - return true; |
93 |
| - } |
94 |
| - return group.equals("com.sun.activation"); |
| 78 | + return PROHIBITED_GROUPS.contains(id.getGroup()) || prohibitedJavax(id) || prohibitedSlf4j(id) |
| 79 | + || prohibitedJbossSpec(id); |
| 80 | + } |
| 81 | + |
| 82 | + private boolean prohibitedSlf4j(ModuleVersionIdentifier id) { |
| 83 | + return id.getGroup().equals("org.slf4j") && id.getName().equals("jcl-over-slf4j"); |
| 84 | + } |
| 85 | + |
| 86 | + private boolean prohibitedJbossSpec(ModuleVersionIdentifier id) { |
| 87 | + return id.getGroup().startsWith("org.jboss.spec"); |
| 88 | + } |
| 89 | + |
| 90 | + private boolean prohibitedJavax(ModuleVersionIdentifier id) { |
| 91 | + return id.getGroup().startsWith("javax.") && !PERMITTED_JAVAX_GROUPS.contains(id.getGroup()); |
95 | 92 | }
|
96 | 93 |
|
97 | 94 | }
|
0 commit comments