Child pages
  • Indore 10 EAP2 (build 41463) Release Notes

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example of a Project defined in Kotlin DSL:

 

Code Block
languagejava
object Project : KProject({
    uuid = "my_project_id" // uuid should be some constant, never changing string; it is important for preserving history, new id means new entity with new history
    extId = "ExampleOfDSL"
    parentId = "_Root" // id of the parent project
    name = "Example of DSL"

    val vcsRoot = vcsRoot {
        uuid = "my_vcs_root_id" 
        extId = "ExampleOfDSL_VcsRoot"
        type = "jetbrains.git" // other available types: svn, perforce, tfs, mercurial, starteam, cvs, vault-vcs
        name = "Example of DSL VCS Root"
        param("url", "<url to my git repository>")
    }

    buildType {
        uuid = "my_build_type_id"
        extId = "ExampleOfDSL_Build"
        name = "Build"

        vcs {
             entry(vcsRoot) // thanks to Kotlin, here we can have static reference to project VCS root
        }

        steps {
             step {
                  type = "Maven2"
                  param("goals", "clean test")
             }
        }

        options {
             buildNumberPattern = "%build.counter%"
        }

        requirements {
             contains("teamcity.agent.jvm.os.name", "Linux")
        }
    }
})
 


Since this is essentially Kotlin code, you can do whatever you like, add conditions, loops, methods, classes, etc. Note that for your convenience the methods buildType(), vcsRoot() and others not only accept some instance, they also return it as a result. In the example above you can see how the vcsRoot instance can be reused in the build configuration. 

...