On 12/01/2011, at 8:41 AM, Sean Van Buggenum wrote:

> Hi Kaptain,
> 
> and thanks very much for the reply.
> 
> I am as much a newbie to groovy as I am to gradle, so obvious
> alternatives such as what you provided do not automatically jump to
> mind.
> And it is enough to go on with. Thanks very much. Yet, it would be
> helpful to see if the original cause of my problem can be solved,
> if for no other reason as my further education in gradle, and to be
> able to better cope with the situation in the future, or if perhaps
> there is no such viable alternative next time.
> 
> Here is the information regarding what I am trying to call, and how;
> 
> The ant task:
> definition: http://subclipse.tigris.org/svnant/svn.html#info
> source: 
> http://subclipse.tigris.org/source/browse/*checkout*/subclipse/trunk/svnant/src/main/org/tigris/subversion/svnant/commands/Info.java?revision=4108&content-type=text/plain
> 
> A reduced version of the gradle script:
> 
> 
> /*
> *  print any required properties to stout, and setup any type def's
> required for custom ant tasks etc
> */
> task checkArgs () {
> 
>  if (getProject().properties['forceBuild']==null)
>  getProject().setProperty('forceBuild', 'false')
> 
>  ant.taskdef(resource: 'org/tigris/subversion/svnant/svnantlib.xml') {
>                       classpath {
>                                       fileset(dir: "${depends_svnant}", 
> includes: 'lib/**/*.jar')
>                       }
>       }
> }
> 
> 
> 
> 
> 
> /*
> * Here we check if the current working directory is old, and if so, we
> know we need to update before building
> * We do this by checking the difference in revision between the
> working dir, and the repo head revision
> */
> task prepareBuildProcess(dependsOn: [checkArgs]){
> 
>               println "Checking path: ${workspaceRoot}/.svn\n"
>               if (new File("${workspaceRoot}/.svn").isDirectory()){
>                       // there is the possibility that no changes have 
> occurred since the
> last build.
>                       // if this is the case, do not proceed. Log the reason 
> why!
>                       println "Trunk exists! Testing trunk for changes."
>                       def lastVersion
>                       new 
> File("${workspaceRoot}/${product}/src/META-INF/MANIFEST.MF").eachLine
> { line ->
>                               if ((matcher = line =~ 
> /[Ii]mplementation-[Vv]ersion:\s*(.*)/)) {
>                                       lastVersion = matcher[0][1].trim()
>                               }
>                       }
>                       
>                       println "last version: " + lastVersion
>                       
>                       println "getting svn repo info, using details 
> username=${svn_user}
> password=${svn_pass}"
>                       ant.svn(javahl: 'false', svnkit: 'false', 
> username:"${svn_user}",
> password: "${svn_pass}"){
>        info(target: "${workspaceRoot}", propPrefix: 'svnInfoWorking',
> verbose: 'true')
>        info(target: "${svn_repo_root}/${product}/${project_branch}",
> propPrefix: 'svnInfoRepo', verbose: 'true')
> 
>        println "Revision is: " +
> ant.getProject().properties['svnInfoWorking.rev']
>        println "\nGet of revision doesn't work yet, problems with
> svnant from gradle. So we at the moment simply always build the
> trunk\n"
>        // here, instead, we should be doing a comparison to see if
> svnInfoWorking.rev = svnInfoRepo.rev are the same
>        // not simply assigning isBuildRequired to true
>        isBuildRequired = true
> 
>                               if (forceBuild =='true'){
>                                       isBuildRequired = true;
>                                       println "Build forced .... commencing"
>                               }
>                       }
>               }
>               else{
>                       println "building the trunk\n\n"
>                       isFullCheckoutRequired = true
>                       isBuildRequired = true          
>               }
> 
> }

You might want to use << when you define the checkArgs and prepareBuildProcess 
tasks. When you leave out the <<, the code in the closure executes at 
configuration time, ie when the build script executes.


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz

Reply via email to