Skip to content

Commit 7581966

Browse files
committed
Merge pull request #136 from advayDev1/fixLogs
Use proper Groovy logging in J2objcUtils.
2 parents 0809319 + 217ceb4 commit 7581966

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main/groovy/com/github/j2objccontrib/j2objcgradle/tasks/J2objcUtils.groovy

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616

1717
package com.github.j2objccontrib.j2objcgradle.tasks
18+
19+
import groovy.util.logging.Slf4j
1820
import org.gradle.api.InvalidUserDataException
1921
import org.gradle.api.Project
2022
import org.gradle.api.file.FileCollection
@@ -24,6 +26,9 @@ import org.gradle.api.tasks.SourceSet
2426
/**
2527
* Internal utilities supporting plugin implementation.
2628
*/
29+
// Without access to the project, logging is performed using the
30+
// static 'log' variable added during decoration with this annotation.
31+
@Slf4j
2732
class J2objcUtils {
2833
// TODO: ideally bundle j2objc binaries with plugin jar and load at runtime with
2934
// TODO: ClassLoader.getResourceAsStream(), extract, chmod and then execute
@@ -122,7 +127,7 @@ class J2objcUtils {
122127
props.putAll(newProps)
123128
}
124129
// for (key in props.keys()) {
125-
// logger.debug key + ": " + props.getProperty(key)
130+
// log.debug key + ": " + props.getProperty(key)
126131
// }
127132

128133
return props
@@ -153,7 +158,7 @@ class J2objcUtils {
153158
static def addJavaFiles(Project proj, FileCollection files, List<String> generatedSourceDirs) {
154159
if (generatedSourceDirs.size() > 0) {
155160
generatedSourceDirs.each { sourceDir ->
156-
logger.debug "include generatedSourceDir: " + sourceDir
161+
log.debug "include generatedSourceDir: " + sourceDir
157162
def buildSrcFiles = proj.files(proj.fileTree(dir: sourceDir, includes: ["**/*.java"]))
158163
files += buildSrcFiles
159164
}
@@ -165,7 +170,7 @@ class J2objcUtils {
165170
if (relativePaths.size() > 0) {
166171
def tmpPaths = ""
167172
relativePaths.each { relativePath ->
168-
logger.debug "Added to Path: " + relativePath
173+
log.debug "Added to Path: " + relativePath
169174
tmpPaths += ":${proj.file(relativePath).path}"
170175
}
171176
return tmpPaths
@@ -201,15 +206,13 @@ class J2objcUtils {
201206
static int matchNumberRegex(String str, String regex) {
202207
def matcher = (str =~ regex)
203208
if (!matcher.find()) {
204-
// Can't use logger.error for output of str, so put it in the exception
205209
throw new IllegalArgumentException(
206210
"${str}\n" +
207211
"\n" +
208212
"Regex couldn't match number in output: ${regex}")
209213
} else {
210214
def value = matcher[0][1]
211215
if (!value.isInteger()) {
212-
// Can't use logger.error for output of str, so put it in the exception
213216
throw new IllegalArgumentException(
214217
"${str}\n" +
215218
"\n" +

0 commit comments

Comments
 (0)