Skip to content

Commit

Permalink
LintRuleDescriptor: stop using GUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Feb 3, 2023
1 parent 10d25f4 commit 8f612f5
Showing 1 changed file with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,52 @@
package com.netflix.nebula.lint.plugin

import groovy.transform.Canonical
import org.gradle.util.GUtil
import org.gradle.api.UncheckedIOException

import javax.annotation.Nullable

@Canonical
class LintRuleDescriptor {
URL propertiesFileUrl

String getImplementationClassName() {
GUtil.loadProperties(propertiesFileUrl).getProperty('implementation-class')
loadProperties(propertiesFileUrl).getProperty('implementation-class')
}

List<String> getIncludes() {
GUtil.loadProperties(propertiesFileUrl).getProperty('includes')?.split(',') ?: [] as List<String>
loadProperties(propertiesFileUrl).getProperty('includes')?.split(',') ?: [] as List<String>
}

private static Properties loadProperties(URL url) {
try {
URLConnection uc = url.openConnection()
uc.setUseCaches(false)
return loadProperties(uc.inputStream)
} catch (IOException e) {
throw new UncheckedIOException(e)
}
}

private static Properties loadProperties(InputStream inputStream) {
Properties properties = new Properties()
try {
properties.load(inputStream)
} catch (IOException e) {
throw new UncheckedIOException(e)
} finally {
closeQuietly(inputStream)
}

return properties
}

private static void closeQuietly(@Nullable Closeable resource) {
try {
if (resource != null) {
resource.close()
}
} catch (IOException e) {
}

}
}

0 comments on commit 8f612f5

Please sign in to comment.