|
46 | 46 | import org.apache.maven.shared.artifact.filter.AbstractStrictPatternArtifactFilter;
|
47 | 47 | import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter;
|
48 | 48 | import org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter;
|
49 |
| -import org.codehaus.plexus.util.IOUtil; |
50 | 49 | import org.eclipse.aether.RepositorySystem;
|
51 | 50 |
|
52 | 51 | /**
|
@@ -154,7 +153,7 @@ static String renderVersion(int major, int minor) {
|
154 | 153 | private String message;
|
155 | 154 |
|
156 | 155 | /**
|
157 |
| - * JDK version as used for example in the maven-compiler-plugin: 1.5, 1.6 and so on. If in need of more precise |
| 156 | + * JDK version as used for example in the maven-compiler-plugin: 8, 11 and so on. If in need of more precise |
158 | 157 | * configuration please see {@link #maxJavaMajorVersionNumber} and {@link #maxJavaMinorVersionNumber} Mandatory if
|
159 | 158 | * {@link #maxJavaMajorVersionNumber} not specified.
|
160 | 159 | */
|
@@ -224,14 +223,13 @@ private void computeParameters() throws EnforcerRuleException {
|
224 | 223 | }
|
225 | 224 | if (maxJdkVersion == null && maxJavaMajorVersionNumber == -1) {
|
226 | 225 | throw new IllegalArgumentException(
|
227 |
| - "Exactly one of maxJdkVersion or " + "maxJavaMajorVersionNumber options should be set."); |
| 226 | + "Exactly one of maxJdkVersion or maxJavaMajorVersionNumber options should be set."); |
228 | 227 | }
|
229 | 228 | if (maxJdkVersion != null) {
|
230 | 229 | Integer needle = JDK_TO_MAJOR_VERSION_NUMBER_MAPPING.get(maxJdkVersion);
|
231 | 230 | if (needle == null) {
|
232 | 231 | throw new IllegalArgumentException(
|
233 |
| - "Unknown JDK version given. Should be something like " |
234 |
| - + "\"1.7\", \"8\", \"11\", \"12\", \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\""); |
| 232 | + "Unknown JDK version given. Should be something like \"8\", \"11\", \"17\", \"21\" .."); |
235 | 233 | }
|
236 | 234 | maxJavaMajorVersionNumber = needle;
|
237 | 235 | if (!strict && needle < 53) {
|
@@ -291,25 +289,16 @@ private String isBadArtifact(Artifact a) throws EnforcerRuleException {
|
291 | 289 | }
|
292 | 290 | }
|
293 | 291 |
|
294 |
| - InputStream is = null; |
295 |
| - try { |
296 |
| - is = jarFile.getInputStream(entry); |
| 292 | + try (InputStream is = jarFile.getInputStream(entry)) { |
297 | 293 | int total = magicAndClassFileVersion.length;
|
298 | 294 | while (total > 0) {
|
299 | 295 | int read =
|
300 | 296 | is.read(magicAndClassFileVersion, magicAndClassFileVersion.length - total, total);
|
301 |
| - |
302 | 297 | if (read == -1) {
|
303 | 298 | throw new EOFException(f.toString());
|
304 | 299 | }
|
305 |
| - |
306 | 300 | total -= read;
|
307 | 301 | }
|
308 |
| - |
309 |
| - is.close(); |
310 |
| - is = null; |
311 |
| - } finally { |
312 |
| - IOUtil.close(is); |
313 | 302 | }
|
314 | 303 |
|
315 | 304 | int minor = (magicAndClassFileVersion[4] << 8) + magicAndClassFileVersion[5];
|
|
0 commit comments