|
17 | 17 | package com.netflix.nebula.lint.plugin
|
18 | 18 |
|
19 | 19 | import groovy.transform.Canonical
|
20 |
| -import org.gradle.util.GUtil |
| 20 | +import org.gradle.api.UncheckedIOException |
| 21 | + |
| 22 | +import javax.annotation.Nullable |
21 | 23 |
|
22 | 24 | @Canonical
|
23 | 25 | class LintRuleDescriptor {
|
24 | 26 | URL propertiesFileUrl
|
25 | 27 |
|
26 | 28 | String getImplementationClassName() {
|
27 |
| - GUtil.loadProperties(propertiesFileUrl).getProperty('implementation-class') |
| 29 | + loadProperties(propertiesFileUrl).getProperty('implementation-class') |
28 | 30 | }
|
29 | 31 |
|
30 | 32 | List<String> getIncludes() {
|
31 |
| - GUtil.loadProperties(propertiesFileUrl).getProperty('includes')?.split(',') ?: [] as List<String> |
| 33 | + loadProperties(propertiesFileUrl).getProperty('includes')?.split(',') ?: [] as List<String> |
| 34 | + } |
| 35 | + |
| 36 | + private static Properties loadProperties(URL url) { |
| 37 | + try { |
| 38 | + URLConnection uc = url.openConnection() |
| 39 | + uc.setUseCaches(false) |
| 40 | + return loadProperties(uc.inputStream) |
| 41 | + } catch (IOException e) { |
| 42 | + throw new UncheckedIOException(e) |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + private static Properties loadProperties(InputStream inputStream) { |
| 47 | + Properties properties = new Properties() |
| 48 | + try { |
| 49 | + properties.load(inputStream) |
| 50 | + } catch (IOException e) { |
| 51 | + throw new UncheckedIOException(e) |
| 52 | + } finally { |
| 53 | + closeQuietly(inputStream) |
| 54 | + } |
| 55 | + |
| 56 | + return properties |
| 57 | + } |
| 58 | + |
| 59 | + private static void closeQuietly(@Nullable Closeable resource) { |
| 60 | + try { |
| 61 | + if (resource != null) { |
| 62 | + resource.close() |
| 63 | + } |
| 64 | + } catch (IOException e) { |
| 65 | + } |
| 66 | + |
32 | 67 | }
|
33 | 68 | }
|
0 commit comments