All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nebula.test.multiproject.MultiProjectHelper.groovy Maven / Gradle / Ivy

There is a newer version: 10.6.1
Show newest version
package nebula.test.multiproject

import groovy.transform.CompileStatic
import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder

@CompileStatic
class MultiProjectHelper {
    Project parent

    MultiProjectHelper(Project parent) {
        this.parent = parent
    }

    Map create(Collection projectNames) {
        Map info = [:]

        projectNames.each {
            def subproject = ProjectBuilder.builder().withName(it).withParent(parent).build()
            info[it] = new MultiProjectInfo(name: it, project: subproject, parent: parent)
        }

        info
    }

    Map createWithDirectories(Collection projectNames) {
        Map info = [:]

        projectNames.each {
            def subDirectory = new File(parent.projectDir, it)
            subDirectory.mkdirs()
            def subproject = ProjectBuilder.builder().withName(it).withProjectDir(subDirectory).withParent(parent).build()
            info[it] = new MultiProjectInfo(name: it, project: subproject, parent: parent, directory: subDirectory)
        }

        info
    }

    Project addSubproject(String name) {
        ProjectBuilder.builder().withName(name).withParent(parent).build()
    }

    Project addSubprojectWithDirectory(String name) {
        def dir = new File(parent.projectDir, name)
        dir.mkdirs()
        ProjectBuilder.builder().withName(name).withProjectDir(dir).withParent(parent).build()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy