From b55a44b42f5850511b5bb773955d24abdd8e7798 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 11 Feb 2016 21:30:38 -0800 Subject: [PATCH] Update archetype doc. --- documentation/index.html | 8 ++-- getting-started/index.html | 75 +++++++++++++--------------------- plug-in-development/index.html | 11 ++--- ten-minutes/index.html | 9 ++-- 4 files changed, 43 insertions(+), 60 deletions(-) diff --git a/documentation/index.html b/documentation/index.html index ab9d044..b11f85f 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -454,10 +454,10 @@ New versions found: --init - Boolean - false - Initialize a project for Kobalt. - This option will create a build file in the current directory (unless one already exists) and will install the Kobalt wrapper. + Comma-separated strings + null + Initialize a project for Kobalt with the given archetypes. + The parameter to this argument is a list of archetype names separated by commas, e.g. "java,myProject". Each archetype will be invoked in order so they can generate their files. --log diff --git a/getting-started/index.html b/getting-started/index.html index c5923e4..a569246 100644 --- a/getting-started/index.html +++ b/getting-started/index.html @@ -58,72 +58,55 @@ unzip kobalt-xxx.zip

 cd ~/java/project
-$KOBALT_HOME/kobaltw --init
+$KOBALT_HOME/kobaltw --init java
 

This command will do two things:

    -
  1. Create a default kobalt/src/Build.kt file based on what was found in your project. -
  2. Install the Kobalt Wrapper in your current directory (a script called kobaltw) and a few additional files in the kobalt/wrapper directory. From now on, you can just use ./kobaltw to build and you can ignore $KOBALT_HOME. -
-

- You can now attempt to build your project with Kobalt: -

+
  • Create a default kobalt/src/Build.kt suitable for a brand new Java project. +
  • Install the Kobalt Wrapper in your current directory (a script called kobaltw) and a few additional files in the kobalt/wrapper directory. From now on, you can just use ./kobaltw to build and you can ignore $KOBALT_HOME. + +

    +You can now attempt to build your project with Kobalt: +

     ./kobaltw assemble
     
    - If your project follows a regular build structure (e.g. Maven's hierarchy), this should compile your file and create a .jar file. If not, you will have to make a few edits to your Build.kt. - As of this writing, Kobalt supports Java and Kotlin projects. - -

    3. Edit kobalt/src/Build.kt

    +If your project follows a regular build structure (e.g. Maven's hierarchy), this should compile your file and create a .jar file. If not, you will have to make a few edits to your Build.kt. +As of this writing, Kobalt supports Java and Kotlin projects. - Here is the Build.kt for the Wasabi HTTP framework: +

    3. Edit kobalt/src/Build.kt

    + +

    The build file generated by default might need some editing before you can build your project, so take a look at it and adjust whatever is necessary (e.g. package name, version, etc...)

    +

    +Here is the Build.kt for the JCommander project: +

     import com.beust.kobalt.*
    -import com.beust.kobalt.plugin.packaging.assemble
    -import com.beust.kobalt.plugin.kotlin.*
    +import com.beust.kobalt.plugin.java.*
    +import com.beust.kobalt.plugin.packaging.*
    +import com.beust.kobalt.plugin.publish.*
     
    -val kotlinVersion = "1.0.0-beta-4583"
    -
    -val p = kotlinProject {
    -
    -    name = "wasabi"
    -    group = "com.example"
    +val jcommander = project {
    +    name = "jcommander"
    +    group = "com.beust"
         artifactId = name
    -    version = "0.1"
    +    version = "1.54"
     
    -    // Tell Kobalt to also search here for dependencies
    -    val repos = repos("http://oss.sonatype.org/content/repositories/snapshots") 
    -
    -    dependencies {
    -        compile("org.jetbrains.kotlin:kotlin-stdlib:" + kotlinVersion,
    -            "org.jetbrains.kotlin:kotlin-reflect:" + kotlinVersion,
    -
    -            "io.netty:netty-all:4.0.31.Final",
    -            "commons-codec:commons-codec:1.6",
    -            "commons-logging:commons-logging:1.1.1",
    -            "joda-time:joda-time:2.3")
    -    }
    -
    -    // Test dependencies
         dependenciesTest {
    -        compile("junit:junit:4.9",
    -            "org.mockito:mockito-all:1.9.5",
    -            "org.apache.httpcomponents:httpclient:4.5.1")
    +        compile("org.testng:testng:6.9.9")
         }
     
    -    // Tell kobalt to produce a fat jar and also the artifacts required for Maven
         assemble {
    -        jar {
    -            fatJar=true
    -            name = "wasabi-fat-" + version + ".jar"
    -        }
    -        mavenJars{
    +        mavenJars {
             }
         }
    -}
    -
    + + jcenter { + publish = true + } +}

    4. Sync your build file

    diff --git a/plug-in-development/index.html b/plug-in-development/index.html index e96eb76..85dd34b 100644 --- a/plug-in-development/index.html +++ b/plug-in-development/index.html @@ -111,7 +111,7 @@ class JavaPlugin : ICompilerContributor, IDocContributor {

     class JavaBuildGenerator: IInitContributor {

    - This class is declaring that it wants to take part in the --init selection process, discussed below. + This class is declaring that it wants to take part in the --init process (i.e. it can generate an archetype), discussed below.

    List of plug-in actors

    @@ -187,10 +187,11 @@ class JavaBuildGenerator: IInitContributor { IInitContributor IContributor - Kobalt supports the --init command line parameter, which generates a default build file - based on the files found in the current directory. Any plug-in that wants to be part of this process need - to implement this interface. In this case, both the Java and Kotlin plug-ins define such a contributor - but future plug-ins might use this contributor to generate their own build file: Android, Ceylon, Spring, etc... + When invoked with --init followed by archetype names separated by commas, + Kobalt will invoke each of these contributors so they can generate their files. + Archetypes are useful to create projects from scratch with a minimal number of + files to get started. For example, the "java" archetype will generate a `Build.kt` + file suitable for a brand new Java project. diff --git a/ten-minutes/index.html b/ten-minutes/index.html index 84897a8..8fbb71c 100644 --- a/ten-minutes/index.html +++ b/ten-minutes/index.html @@ -75,13 +75,12 @@ $ mkdir linecount $ cd linecount $ mkdir -p src/main/kotlin/com/beust/plugin/linecount -$ touch src/main/kotlin/com/beust/plugin/linecount/Main.kt -$ $KOBALT_HOME/kobaltw --init +$ $KOBALT_HOME/kobaltw --init kotlin -

    - I create an empty Main.kt in the example above so that calling ./kobaltw --init will detect the project as a Kotlin one. This way, the Build.kt file generated is already configured for Kotlin. Since we will be publishing this project to a Maven repository, we need to make sure that its group, artifactId and version are correct. The only thing that the generator can't guess is the group, so let's go ahead and fix it: -

    +

    + ./kobaltw --init kotlin creates an empty Kotlin project. Since we will be publishing this project to a Maven repository, we need to make sure that its group, artifactId and version are correct. The only thing that the generator can't guess is the group, so let's go ahead and fix it: +

     val project = kotlinProject {