view init.gradle @ 79:f0c29c1ac1f4

finish gradle to artifactory publishing
author smith@nwoca.org
date Tue, 07 Feb 2012 22:21:53 -0500
parents e47f80ef056b
children 647840c0753d
line wrap: on
line source


gradle.addListener(new ArtifactoryGradleSettings())

gradle.bambooBuild = System.getenv().any { it.key.startsWith('BAMBOO')}
logger.info "applying SSDT artifactory Gradle Settings (bamboo: $gradle.bambooBuild)"

if (gradle.bambooBuild) {
   apply from: "${gradle.hasProperty('ssdtGradlekitLocation') ? gradle.ssdtGradlekitLocation :'http://hg.ssdt-ohio.org/browse/ssdt/gradlekit'}/artifactory.gradle"
}

subprojects {
    task cleanLocal << {
        def local = project.repositories.find { it.name == 'local' } 
        if ( local ) {                
            local.dirs.each { 
                logger.info "removing local repo: $it"
                it.deleteDir() 
            }
        }
    }    
    cleanLocal.onlyIf { 
        project.repositories.find { it.name == 'local' }?.dirs.any { it.exists() } 
    }    
    task publishLocal(dependsOn: 'uploadArchives')  << { println "published to local repository" }
}

class ArtifactoryGradleSettings extends BuildAdapter implements BuildListener {
    
    def void projectsEvaluated(Gradle gradle) {
        
        Project root = gradle.getRootProject()       
        root.subprojects {
        
            configurations.all {
                resolutionStrategy.cacheChangingModulesFor 120, 'minutes'
                resolutionStrategy.cacheDynamicVersionsFor 120, 'minutes'
            }        
            repositories {
                if (!gradle.bambooBuild) {
                    flatDir {
                        name "local"
                        dirs System.properties['user.home'] + "/.ssdt/local-repo"
                    }    
                }                
                add(new org.apache.ivy.plugins.resolver.URLResolver()) {
                  name = 'ssdt-snapshots'
                  m2compatible =  true
                  url = 'http://repos.ssdt.nwoca.org/artifactory/ssdt-snapshots'
                  addArtifactPattern('http://repos.ssdt.nwoca.org/artifactory/ssdt-snapshots/[organization]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]')
                  addIvyPattern('http://repos.ssdt.nwoca.org/artifactory/ssdt-snapshots/[organization]/[module]/ivy-[revision].xml')
                  checkmodified = true
                  changingMatcher = 'regexp'
                  changingPattern = '.*SNAPSHOT'                  
                }
                add(new org.apache.ivy.plugins.resolver.URLResolver()) {
                  name = 'ssdt-releases'
                  m2compatible = false
                  url = 'http://repos.ssdt.nwoca.org/artifactory/ssdt-releases'
                  addArtifactPattern('http://repos.ssdt.nwoca.org/artifactory/ssdt-releases/[organization]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]')
                  addIvyPattern('http://repos.ssdt.nwoca.org/artifactory/ssdt-releases/[organization]/[module]/ivy-[revision].xml')
                }
                mavenRepo name: 'ssdt-repo', url: 'http://repos.ssdt.nwoca.org/artifactory/ssdt-repo'
                 
            }           
              
            uploadArchives {
                repositories {
                    if ( project.repositories.find { it.name == 'local' } ) {                
                        add project.repositories.local
                    }
                }
            }          
        }
    }
}