1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt-doc.git synced 2025-04-25 12:07:10 -07:00

Update archetype doc.

This commit is contained in:
Cedric Beust 2016-02-11 21:30:38 -08:00
parent 81ef95763e
commit b55a44b42f
4 changed files with 43 additions and 60 deletions

View file

@ -454,10 +454,10 @@ New versions found:
</tr> </tr>
<tr> <tr>
<td><code>--init</code></td> <td><code>--init</code></td>
<td>Boolean</td> <td>Comma-separated strings</td>
<td>false</td> <td>null</td>
<td>Initialize a project for Kobalt.</td> <td>Initialize a project for Kobalt with the given archetypes.</td>
<td>This option will create a build file in the current directory (unless one already exists) and will install the Kobalt wrapper.</td> <td>The parameter to this argument is a list of archetype names separated by commas, e.g. <code>"java,myProject"</code>. Each archetype will be invoked in order so they can generate their files.</td>
</tr> </tr>
<tr> <tr>
<td><code>--log</code></td> <td><code>--log</code></td>

View file

@ -58,13 +58,13 @@ unzip kobalt-xxx.zip
</p> </p>
<pre class="brush:plain"> <pre class="brush:plain">
cd ~/java/project cd ~/java/project
$KOBALT_HOME/kobaltw --init $KOBALT_HOME/kobaltw --init java
</pre> </pre>
<p> <p>
This command will do two things: This command will do two things:
</p> </p>
<ol> <ol>
<li>Create a default <code>kobalt/src/Build.kt</code> file based on what was found in your project. <li>Create a default <code>kobalt/src/Build.kt</code> suitable for a brand new Java project.
<li>Install the Kobalt Wrapper in your current directory (a script called <code>kobaltw</code>) and a few additional files in the <code>kobalt/wrapper</code> directory. From now on, you can just use <code>./kobaltw</code> to build and you can ignore <code>$KOBALT_HOME</code>. <li>Install the Kobalt Wrapper in your current directory (a script called <code>kobaltw</code>) and a few additional files in the <code>kobalt/wrapper</code> directory. From now on, you can just use <code>./kobaltw</code> to build and you can ignore <code>$KOBALT_HOME</code>.
</ol> </ol>
<p> <p>
@ -78,52 +78,35 @@ $KOBALT_HOME/kobaltw --init
<h2 class="section" id="edit">3. Edit kobalt/src/Build.kt</h2> <h2 class="section" id="edit">3. Edit kobalt/src/Build.kt</h2>
Here is the <code>Build.kt</code> for the <a href="https://github.com/hhariri/wasabi/blob/master/kobalt/src/Build.kt">Wasabi HTTP framework</a>: <p>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...)</p>
<p>
Here is the <code>Build.kt</code> for the <a href="https://github.com/cbeust/jcommander/blob/master/kobalt/src/Build.kt">JCommander project</a>:
</p>
<pre class="brush:java"> <pre class="brush:java">
import com.beust.kobalt.* import com.beust.kobalt.*
import com.beust.kobalt.plugin.packaging.assemble import com.beust.kobalt.plugin.java.*
import com.beust.kobalt.plugin.kotlin.* import com.beust.kobalt.plugin.packaging.*
import com.beust.kobalt.plugin.publish.*
val kotlinVersion = "1.0.0-beta-4583" val jcommander = project {
name = "jcommander"
val p = kotlinProject { group = "com.beust"
name = "wasabi"
group = "com.example"
artifactId = name 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 { dependenciesTest {
compile("junit:junit:4.9", compile("org.testng:testng:6.9.9")
"org.mockito:mockito-all:1.9.5",
"org.apache.httpcomponents:httpclient:4.5.1")
} }
// Tell kobalt to produce a fat jar and also the artifacts required for Maven
assemble { assemble {
jar {
fatJar=true
name = "wasabi-fat-" + version + ".jar"
}
mavenJars { mavenJars {
} }
} }
jcenter {
publish = true
} }
</pre> }</pre>
<h2 class="section" id="idea-plugin">4. Sync your build file</h2> <h2 class="section" id="idea-plugin">4. Sync your build file</h2>
<p> <p>

View file

@ -111,7 +111,7 @@ class JavaPlugin : ICompilerContributor, IDocContributor {</pre>
<pre class="brush:java"> <pre class="brush:java">
class JavaBuildGenerator: IInitContributor {</pre> class JavaBuildGenerator: IInitContributor {</pre>
<p> <p>
This class is declaring that it wants to take part in the <code>--init</code> selection process, discussed below. This class is declaring that it wants to take part in the <code>--init</code> process (i.e. it can generate an archetype), discussed below.
</p> </p>
<h2 class="section" id="actor-list">List of plug-in actors</h2> <h2 class="section" id="actor-list">List of plug-in actors</h2>
<p> <p>
@ -187,10 +187,11 @@ class JavaBuildGenerator: IInitContributor {</pre>
<tr> <tr>
<td><code><a href="https://github.com/cbeust/kobalt/blob/master/src/main/kotlin/com/beust/kobalt/api/IInitContributor.kt">IInitContributor</a></code></td> <td><code><a href="https://github.com/cbeust/kobalt/blob/master/src/main/kotlin/com/beust/kobalt/api/IInitContributor.kt">IInitContributor</a></code></td>
<td><a href="https://github.com/cbeust/kobalt/blob/master/src/main/kotlin/com/beust/kobalt/api/IPluginActor.kt"><code>IContributor</code></a> </td> <td><a href="https://github.com/cbeust/kobalt/blob/master/src/main/kotlin/com/beust/kobalt/api/IPluginActor.kt"><code>IContributor</code></a> </td>
<td>Kobalt supports the <code>--init</code> command line parameter, which generates a default build file <td>When invoked with <code>--init</code> followed by archetype names separated by commas,
based on the files found in the current directory. Any plug-in that wants to be part of this process need Kobalt will invoke each of these contributors so they can generate their files.
to implement this interface. In this case, both the Java and Kotlin plug-ins define such a contributor Archetypes are useful to create projects from scratch with a minimal number of
but future plug-ins might use this contributor to generate their own build file: Android, Ceylon, Spring, etc... files to get started. For example, the "java" archetype will generate a `Build.kt`
file suitable for a brand new Java project.
</td> </td>
</tr> </tr>
<tr> <tr>

View file

@ -75,12 +75,11 @@
$ mkdir linecount $ mkdir linecount
$ cd linecount $ cd linecount
$ mkdir -p src/main/kotlin/com/beust/plugin/linecount $ mkdir -p src/main/kotlin/com/beust/plugin/linecount
$ touch src/main/kotlin/com/beust/plugin/linecount/Main.kt $ $KOBALT_HOME/kobaltw --init kotlin
$ $KOBALT_HOME/kobaltw --init
</pre> </pre>
<p> <p>
I create an empty <code>Main.kt</code> in the example above so that calling <code>./kobaltw --init</code> will detect the project as a Kotlin one. This way, the <code>Build.kt</code> 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 <code>group</code>, <code>artifactId</code> and <code>version</code> are correct. The only thing that the generator can't guess is the <code>group</code>, so let's go ahead and fix it: <code>./kobaltw --init kotlin</code> creates an empty Kotlin project. Since we will be publishing this project to a Maven repository, we need to make sure that its <code>group</code>, <code>artifactId</code> and <code>version</code> are correct. The only thing that the generator can't guess is the <code>group</code>, so let's go ahead and fix it:
</p> </p>
<pre class="brush:java"> <pre class="brush:java">