Return to Snippet

Revision: 4210
at November 7, 2007 07:12 by cfrias


Initial Code
class MavenDependency {
    static void require(params) {
        MavenDependencyHelper.getInstance().require(params)
    }
    static MavenDependencyHelper using(classLoader) {
        MavenDependencyHelper.getInstance(classLoader)
    }
}

private class MavenDependencyHelper {
    private classLoader
    private MavenDependencyHelper(classLoader) {
        this.classLoader = classLoader
    }

    static MavenDependencyHelper getInstance(classLoader) {
        return new MavenDependencyHelper(classLoader)
    }

    static MavenDependencyHelper getInstance() {
        return new MavenDependencyHelper(MavenDependencyHelper.classLoader)
    }

    MavenDependencyHelper require(params) {
        def ant = new AntBuilder()
        def mvn = groovy.xml.NamespaceBuilder.newInstance(ant, 'antlib:org.apache.maven.artifact.ant')
        mvn.dependencies(filesetId:"artifact_${params.groupId}_${params.artifactId}_${params.version}") { dependency(params) }
        ant.fileScanner { fileset(refid:"artifact_${params.groupId}_${params.artifactId}_${params.version}") }.each {
            classLoader.addClasspath(it.toString())
        }
        this
    }
}

Initial URL

                                

Initial Description
The base MavenDependency Script

Initial Title
Maven 2 Ant Tasks - MavenDependency Script

Initial Tags

                                

Initial Language
Groovy