GeneralConfig.md
May 30, 2017 ยท View on GitHub
General Configuration
The svntools block (implemented by SvnToolsPluginExtension) can be used to
- specify default values for some configuration properties:
- 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.committedDate The last committed Date (java.util.Date)
- info.committedAuthor The last committer
- 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.
SVN credentials
It isn't a good idea to include usernames and passwords in the build script. Instead, add them to the ~/gradle.properties file:
svnUsername = foo
svnPassword = bar
Now, these values can be used within the build script like regular variables:
task svnStatus(type: at.bxm.gradleplugins.svntools.tasks.SvnInfo) {
username = svnUsername // credentials for the current task only
password = svnPassword
}
svntools {
username = svnUsername // credentials for all tasks
password = svnPassword
}
Instead of username = svnUsername, write username = findProperty("svnUsername") to avoid an error if that value doesn't exist.
Example
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"
}
}
Using a Proxy Server
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):
Specify the proxy settings in build.gradle
svntools {
proxy.host = "[hostname]"
proxy.port = [portnumber]
proxy.username = "[username]"
proxy.password = "[password]"
proxy.nonProxyHosts = "127.0.0.1|localhost|companysvn"
}
This way, the proxy settings are only applied to the svn-tools-plugin and are ignored by Gradle.
Specify the proxy settings at the command line
gradlew -Dhttp.proxyHost=[hostname] \
-Dhttp.proxyPort=[portnumber] \
-Dhttp.proxyUser=[username] \
-Dhttp.proxyPassword=[password] \
-Dhttp.nonProxyHosts=[list_of_hostnames] \
[taskname]
Now all tasks of the current Gradle execution are using the proxy server (e.g. dependencies are downloaded through the proxy server)
Specify the proxy settings in ~/gradle.properties
systemProp.http.proxyHost = [hostname]
systemProp.http.proxyPort = [portnumber]
systemProp.http.proxyUser = [username]
systemProp.http.proxyPassword = [password]
systemProp.http.nonProxyHosts = [list_of_hostnames]
Every Gradle execution will use the proxy server.