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

Merge branch 'master' of github.com:cbeust/kobalt-doc

This commit is contained in:
Cedric Beust 2015-11-03 07:07:08 -08:00
commit 46d21db94e
4 changed files with 55 additions and 51 deletions

View file

@ -105,7 +105,7 @@ As of this writing, Kobalt supports Java and Kotlin projects.
<h3 class="section" indent="1" id="general-concepts">General concepts</h3> <h3 class="section" indent="1" id="general-concepts">General concepts</h3>
<p> <p>
The build file is typically called <code>Built.kt</code> and it is a valid Kotlin file. Typically, it contains imports, the declaration of one or more projects and the declaration of additional configurations (e.g. packaging, publishing, etc...). Since it's a Kotlin file, it can also contain any class or function you need: The build file is typically called <code>Built.kt</code> and it is a valid Kotlin file. It contains imports, the declaration of one or more projects and the declaration of additional configurations (e.g. packaging, publishing, etc...). Since it's a Kotlin file, it can also contain any class or function you need:
</p> </p>
<pre> <pre>
@ -124,34 +124,39 @@ val kobalt = kotlinProject {
Here are a few noteworthy details about this small build file: Here are a few noteworthy details about this small build file:
<ul> <ul>
<li>You have now declared a variable called <code>kobalt</code> which you can reuse (see below). <li>You have now declared a variable called <code>kobalt</code> which you can reuse further in your build file, should you ever need to.
<li>You can specify the directory of the project, which means that one build file can be used to build multiple projects. <li>You can specify the directory of the project, which means that one build file can be used to build multiple projects.
<li>The functions <code>kotlinProject</code> and <code>homeDir</code> are supplied by Kobalt and are sometimes referred to as "directives" <li>The functions <code>kotlinProject</code> and <code>homeDir</code> are supplied by Kobalt and are referred to as "directives"
</ul> </ul>
<h3 class="section" indent="1" id="directives">Directives</h3> <h3 class="section" indent="1" id="directives">Directives</h3>
<p> <p>
Now that we have declared a project, we can use it to configure additional steps of our build, such as the assembling it (creating jar and other files: Now that we have declared a project, we can use it to configure additional steps of our build, such as how to assemble it (creating jar and other files):
</p> </p>
<pre> <pre>
import com.beust.kobalt.plugin.packaging.assemble import com.beust.kobalt.plugin.packaging.assemble
// ... val kobalt = kotlinProject {
// ...
val packKobalt = assemble(kobalt) { <b>
assemble {
jar { jar {
} }
</b>
} }
</pre> </pre>
<p> <p>
This is the simplest jar declaration you can have. You can trigger the creation of this jar file by invoking the task <code>"assemble"</code>. Note that we passed the <code>kobalt</code> variable to the <code>assemble</code> function, so we make it clear which project we are currently configuring for packaging. The <code>jar</code> directive accepts various settings, so let's be a bit more specific. And let's add a zip file too: This is the simplest jar declaration you can have. You can trigger the creation of this jar file by invoking the task <code>"assemble"</code> from the command line. Note the presence of the corresponding <code>import</code>: without it, your build file will not compile. Another interesting details is that the <code>assemble</code> function we just imported is an extension function on the <code>Project</code> class, which is how the import makes it legal to call <code>assemble</code> in the middle of our project. If you remove the import, that line will no longer compile.
</p>
<p>
The <code>jar</code> directive accepts various settings, so let's be a bit more specific. And let's add a zip file too:
</p> </p>
<pre> <pre>
val assembleKobalt = assemble(kobalt) { assemble {
jar { jar {
fatJar = true fatJar = true
manifest { manifest {
@ -160,12 +165,11 @@ val assembleKobalt = assemble(kobalt) {
} }
zip { zip {
include("kobaltw") include("kobaltw")
include(from("${kobalt.buildDirectory}/libs"), include(from("$buildDirectory/libs"), to("kobalt/wrapper"),
to("kobalt/wrapper"), "$projectName-$version.jar")
"${kobalt.name}-${kobalt.version}.jar", include(from("modules/wrapper/$buildDirectory/libs"), to("kobalt/wrapper"),
"${kobalt.name}-wrapper.jar") "$projectName-wrapper.jar")
} }
}
</pre> </pre>
<p> <p>
@ -444,13 +448,12 @@ dependencies {
<h4>2. Declare the main class of your plug-in in the Jar file's manifest:</h4> <h4>2. Declare the main class of your plug-in in the Jar file's manifest:</h4>
<pre> <pre>
val p = packaging(examplePlugin) { packaging {
jar { jar {
manifest { manifest {
attributes("Kobalt-Plugin-Class", "com.beust.kobalt.example.ExamplePlugin") attributes("Kobalt-Plugin-Class", "com.beust.kobalt.example.ExamplePlugin")
} }
} }
}
</pre> </pre>
<h3 class="section" indent="1" id="implementing">Implementing</h3> <h3 class="section" indent="1" id="implementing">Implementing</h3>
@ -486,10 +489,9 @@ Next, you can declare tasks with the <code>@Task</code> annotation:
</p> </p>
<pre> <pre>
@Task(name = "coverage", description = "Run coverage", @Task(name = "coverage", description = "Run coverage", runAfter = arrayOf("compile"))
runAfter = arrayOf("compile"))
public fun coverage(project: Project): TaskResult { public fun coverage(project: Project): TaskResult {
println("Running the coverage on project ${project}") println("Running the coverage on project $project")
return TaskResult() return TaskResult()
} }
</pre> </pre>

View file

@ -74,16 +74,17 @@ val jcommander = javaProject {
dependenciesTest { dependenciesTest {
compile("org.testng:testng:6.9.5") compile("org.testng:testng:6.9.5")
} }
}
val a = assemble(jcommander) { assemble {
mavenJars { mavenJars {
} }
}
jcenter {
publish = false
}
} }
val j = jcenter(jcommander) {
publish = false
}
</pre> </pre>
<h2 class="section" id="design-goals">Design goals</h2> <h2 class="section" id="design-goals">Design goals</h2>

View file

@ -101,7 +101,7 @@ Next, we want the manifest of our jar file to point to our main Kobalt plug-in c
</p> </p>
<pre> <pre>
val packProject = packaging(project) { packaging {
jar { jar {
manifest { manifest {
attributes("Kobalt-Plugin-Class", "com.beust.kobalt.plugin.linecount.Main") attributes("Kobalt-Plugin-Class", "com.beust.kobalt.plugin.linecount.Main")
@ -150,7 +150,7 @@ If you go to the maven section of your bintray account, you will now see that th
</p> </p>
<pre> <pre>
val jc = jcenter(project) { jcenter {
publish = true publish = true
} }
</pre> </pre>

View file

@ -113,8 +113,9 @@ The Packaging plug-in lets you generate various archives for your project: jar,
</p> </p>
<pre> <pre>
val packaging = assemble(kobalt) { assemble {
jar {} jar {
}
} }
</pre> </pre>
@ -139,7 +140,7 @@ All archives let you include and exclude files.
</p> </p>
<pre> <pre>
val a = assemble(kobalt) { assemble {
zip { zip {
include("kobaltw", "README") include("kobaltw", "README")
include(from("doc/"), include(from("doc/"),
@ -171,7 +172,7 @@ val a = assemble(kobalt) {
</p> </p>
<pre> <pre>
val a = assemble(kobalt) { assemble {
jar { jar {
fatJar = true fatJar = true
manifest { manifest {
@ -224,7 +225,7 @@ you are ready to do your first upload.
</p> </p>
<pre> <pre>
val jc = jcenter(kobalt) { jcenter {
publish = true publish = true
file("${kobalt.buildDirectory}/libs/${kobalt.name}-${kobalt.version}.zip", file("${kobalt.buildDirectory}/libs/${kobalt.name}-${kobalt.version}.zip",
"${kobalt.name}/${kobalt.version}/${kobalt.name}-${kobalt.version}.zip") "${kobalt.name}/${kobalt.version}/${kobalt.name}-${kobalt.version}.zip")