The svntools
block (implemented by SvnToolsPluginExtension) can be used to
- specify default values for some configuration properties:
- username: The SVN username - leave empty if no authentication is required
- password: The SVN password - leave empty if no authentication is required
- adjust proxy server settings (see below)
- access information about the current SVN workspace root (i.e. the project's root directory), wrapped by an SvnData object:
- info.revisionNumber The SVN revision number
- info.url The complete SVN URL of the checked-out project
- info.repositoryRootUrl The root URL of the SVN repository
- info.name Either "trunk", the name of the current branch, or the name of the current tag
- info.trunk "true" if the SVN URL refers to a trunk
- info.branch "true" if the SVN URL refers to a branch
- info.tag "true" if the SVN URL refers to a tag
- access information about an arbitrary path within an SVN workspace, wrapped by an SvnData object: getInfo("path/file.ext") (see example below)
- access information about a path within a remote SVN repository, wrapped by an SvnData object: getRemoteInfo("repoUrl","path/file.ext") (see example below)
- summarize the local revision(s) of a working copy, wrapped by an SvnVersionData object:
- version svnversion output
- version.mixedRevision "true" if the working copy contains mixed revisions
- version.minRevisionNumber The smallest SVN revision within the working copy
- version.maxRevisionNumber The greatest SVN revision within the working copy
- version.modified "true" if the working copy contains local modifications
- version.sparse "true" if the working copy is sparsely populated (i.e. "depth" is not "infinity")
- version.switched "true" if the parts of the working copy have been switched
Note: The svntools.info
and svntools.version
objects assume that the current Gradle project has been checked out from SVN. To retrieve information about other SVN files or workspaces, use the SvnInfo resp. SvnVersion tasks.
apply plugin: "at.bxm.svntools"
svntools {
username = "john"
password = "secret"
}
task info << {
println "Current revision is $svntools.info.revisionNumber"
}
task specialInfo << {
println "Current revision of 'readme.txt' is " + svntools.getInfo(file("readme.txt"))
}
task remoteInfo << {
try {
println "Remote revision of 'readme.txt' is " + svntools.getRemoteInfo("https://svn.apache.org/repos/asf/subversion", "trunk/readme.txt")
} catch (Exception e) {
println "Remote file is not available: $e.message"
}
}
If a proxy server is needed for connecting to the remote SVN repository, it can be configured in one of the following ways (ordered by precedence):
svntools {
proxy.host = "[hostname]"
proxy.port = [portnumber]
proxy.username = "[username]"
proxy.password = "[password]"
}
This way, the proxy settings are only applied to the svn-tools-plugin and are ignored by Gradle.
gradlew -Dhttp.proxyHost=[hostname] \
-Dhttp.proxyPort=[portnumber] \
-Dhttp.proxyUser=[username] \
-Dhttp.proxyPassword=[password]
[taskname]
Now all tasks of the current Gradle execution are using the proxy server (e.g. dependencies are downloaded through the proxy server)
systemProp.http.proxyHost = [hostname]
systemProp.http.proxyPort = [portnumber]
systemProp.http.proxyUser = [username]
systemProp.http.proxyPassword = [password]
Every Gradle execution will use the proxy server.