By checking the date of the artifact before and after the srchive_jar
task I have been able to solve my problem. Now the jar is uploated
into the repository only when it is changed.

subprojects {
  isNewArchiveJar = false

  task('archive_jar').doFirst { task ->
    jarFile = new File( task.project.buildDir.path+'/'+task.project.name+'.jar')
    if( jarFile.exists() == true ){
       jarLastModifiedDate = jarFile.lastModified()
    }
  }
  task('archive_jar').doLast { task ->
    jarFile = new File( task.project.buildDir.path+'/'+task.project.name+'.jar')
    if( jarFile.exists() == true ){
       if( jarLastModifiedDate != jarFile.lastModified() )
         isNewArchiveJar = true
    }
  }

  task('uploadInternalLibs').doLast { task ->
      if( isNewArchiveJar == true )
        if( isProjectPresent( task.project.name ) )
          ant.copy( file:
task.project.buildDir.path+"/"+task.project.archive_jar.archiveName,
todir: mainRepo.path, overwrite:true)
        }
}

Regards,

Walter

2009/4/24 Walter Di Carlo <[email protected]>:
> Hello,
>
> I have checked both the manual and the forum but I have not find any way to
> see if a artifact (jar) has been re-created.
>
> I need this because I would like to upload the jar to a repository just when
> it is changed.
>
> I have tried with something like the following
>
>     task('uploadInternalLibs').doLast { task ->
>        if( build.taskGraph.hasTask(':'+task.project.name+':compile') == true
> ){
>               ant.copy( file:
> task.project.buildDir.path+"/"+task.project.archive_jar.archiveName, todir:
> mainRepo.path, overwrite:true)
>        }
>     }
>
> but I have discovered that the "compile" task is executed even if it doesn't
> do anything.
>
> I could try to check the date of the jar before and after the archive_jar
> task to see if it is changed, but is this the way to solve my problem in the
> Gradle way?
>
> Regards,
>
> Walter
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to