Skip to content

Commit 56bdd2e

Browse files
authored
Merge pull request #48 from markslater/use-logger-for-output
Use Logger for output
2 parents 8087997 + 920361c commit 56bdd2e

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/main/groovy/net/nemerosa/versioning/VersioningExtension.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class VersioningExtension {
3535
* Registry of release modes
3636
*/
3737
private static final Map<String, Closure<String>> RELEASE_MODES = [
38-
tag : { nextTag, lastTag, currentTag, extension ->
38+
tag : { nextTag, lastTag, currentTag, extension ->
3939
nextTag
4040
},
4141
snapshot: { nextTag, lastTag, currentTag, extension ->
@@ -62,7 +62,7 @@ class VersioningExtension {
6262
* By default, the environment is not taken into account, in order to be backward compatible
6363
* with existing build systems.
6464
*/
65-
List branchEnv = []
65+
List<String> branchEnv = []
6666

6767
/**
6868
* Getting the version type from a branch. Default: getting the part before the first "/" (or a second
@@ -100,7 +100,7 @@ class VersioningExtension {
100100
def releaseMode = 'tag'
101101

102102
/**
103-
* True if it's release build. Default is true, and branch shoud be in releases-set.
103+
* True if it's release build. Default is true, and branch should be in releases-set.
104104
*/
105105
def releaseBuild = true
106106

@@ -131,7 +131,7 @@ class VersioningExtension {
131131
/**
132132
* If set to <code>true</code>, no warning will be printed in case the workspace is dirty.
133133
*/
134-
boolean noWarningOnDirty = false;
134+
boolean noWarningOnDirty = false
135135

136136
/**
137137
* Credentials (for SVN only)
@@ -240,7 +240,7 @@ class VersioningExtension {
240240
throw new DirtyException()
241241
} else {
242242
if (!noWarningOnDirty) {
243-
println "[versioning] WARNING - the working copy has unstaged or uncommitted changes."
243+
project.getLogger().warn("[versioning] WARNING - the working copy has unstaged or uncommitted changes.")
244244
}
245245
versionDisplay = dirty(versionDisplay)
246246
versionFull = dirty(versionFull)
@@ -305,8 +305,8 @@ class VersioningExtension {
305305
}
306306
}
307307

308-
public static String normalise(String value) {
309-
value.replaceAll(/[^A-Za-z0-9\.\-_]/, '-')
308+
static String normalise(String value) {
309+
value.replaceAll(/[^A-Za-z0-9.\-_]/, '-')
310310
}
311311

312312
private static SCMInfoService getSCMInfoService(String type) {

src/main/groovy/net/nemerosa/versioning/svn/SVNInfoService.groovy

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import net.nemerosa.versioning.SCMInfo
44
import net.nemerosa.versioning.SCMInfoService
55
import net.nemerosa.versioning.VersioningExtension
66
import org.gradle.api.Project
7+
import org.gradle.api.logging.Logger
8+
import org.gradle.api.logging.Logging
79
import org.tmatesoft.svn.core.SVNDepth
810
import org.tmatesoft.svn.core.SVNDirEntry
911
import org.tmatesoft.svn.core.SVNException
@@ -14,6 +16,8 @@ import org.tmatesoft.svn.core.wc.*
1416

1517
class SVNInfoService implements SCMInfoService {
1618

19+
private static final Logger LOGGER = Logging.getLogger(this.getClass())
20+
1721
@Override
1822
SCMInfo getInfo(Project project, VersioningExtension extension) {
1923
// Is SVN enabled?
@@ -130,7 +134,7 @@ class SVNInfoService implements SCMInfoService {
130134
}
131135
// Gets the list of tags
132136
String tagsUrl = "${baseUrl}/tags"
133-
println "[version] Getting list of tags from ${tagsUrl}..."
137+
LOGGER.info("[version] Getting list of tags from ${tagsUrl}...")
134138
// Gets the list
135139
List<SVNDirEntry> entries = []
136140
try {
@@ -179,15 +183,15 @@ class SVNInfoService implements SCMInfoService {
179183
protected static SVNClientManager getClientManager(VersioningExtension extension) {
180184
def clientManager = SVNClientManager.newInstance()
181185
if (extension.user && extension.password) {
182-
println "[version] Authenticating with ${extension.user}"
183-
clientManager.setAuthenticationManager(BasicAuthenticationManager.newInstance(extension.user, extension.password.toCharArray()));
186+
LOGGER.info("[version] Authenticating with ${extension.user}")
187+
clientManager.setAuthenticationManager(BasicAuthenticationManager.newInstance(extension.user, extension.password.toCharArray()))
184188
// The BasicAuthenticationManager trusts the certificates by default
185189
} else if (extension.trustServerCert) {
186-
println "[version] Trusting certificate by default"
187-
println "[version] WARNING The `trustServerCert` is now deprecated - and should not be used any longer."
188-
clientManager.setAuthenticationManager(BasicAuthenticationManager.newInstance(new SVNAuthentication[0]));
190+
LOGGER.info("[version] Trusting certificate by default")
191+
LOGGER.warn("[version] WARNING The `trustServerCert` is now deprecated - and should not be used any longer.")
192+
clientManager.setAuthenticationManager(BasicAuthenticationManager.newInstance(new SVNAuthentication[0]))
189193
} else {
190-
println "[version] Using default SVN configuration"
194+
LOGGER.info("[version] Using default SVN configuration")
191195
clientManager.setAuthenticationManager(SVNWCUtil.createDefaultAuthenticationManager())
192196
}
193197
return clientManager

0 commit comments

Comments
 (0)