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

Update to new format.

This commit is contained in:
Cedric Beust 2015-10-29 04:10:45 -07:00
parent 4d4007ab66
commit cf00145b72
4 changed files with 54 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>
<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>
<pre>
@ -124,48 +124,52 @@ val kobalt = kotlinProject {
Here are a few noteworthy details about this small build file:
<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>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>
<h3 class="section" indent="1" id="directives">Directives</h3>
<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>
<pre>
import com.beust.kobalt.plugin.packaging.assemble
// ...
val packKobalt = assemble(kobalt) {
jar {
val kobalt = kotlinProject {
// ...
<b>
assemble {
jar {
}
</b>
}
</pre>
<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>
<pre>
val assembleKobalt = assemble(kobalt) {
jar {
fatJar = true
manifest {
attributes("Main-Class", "com.beust.kobalt.KobaltPackage")
assemble {
jar {
fatJar = true
manifest {
attributes("Main-Class", "com.beust.kobalt.KobaltPackage")
}
}
zip {
include("kobaltw")
include(from("$buildDirectory/libs"), to("kobalt/wrapper"),
"$projectName-$version.jar")
include(from("modules/wrapper/$buildDirectory/libs"), to("kobalt/wrapper"),
"$projectName-wrapper.jar")
}
}
zip {
include("kobaltw")
include(from("${kobalt.buildDirectory}/libs"),
to("kobalt/wrapper"),
"${kobalt.name}-${kobalt.version}.jar",
"${kobalt.name}-wrapper.jar")
}
}
</pre>
<p>
@ -437,13 +441,12 @@ dependencies {
<h4>2. Declare the main class of your plug-in in the Jar file's manifest:</h4>
<pre>
val p = packaging(examplePlugin) {
jar {
manifest {
attributes("Kobalt-Plugin-Class", "com.beust.kobalt.example.ExamplePlugin")
packaging {
jar {
manifest {
attributes("Kobalt-Plugin-Class", "com.beust.kobalt.example.ExamplePlugin")
}
}
}
}
</pre>
<h3 class="section" indent="1" id="implementing">Implementing</h3>
@ -479,10 +482,9 @@ Next, you can declare tasks with the <code>@Task</code> annotation:
</p>
<pre>
@Task(name = "coverage", description = "Run coverage",
runAfter = arrayOf("compile"))
@Task(name = "coverage", description = "Run coverage", runAfter = arrayOf("compile"))
public fun coverage(project: Project): TaskResult {
println("Running the coverage on project ${project}")
println("Running the coverage on project $project")
return TaskResult()
}
</pre>

View file

@ -74,16 +74,16 @@ val jcommander = javaProject {
dependenciesTest {
compile("org.testng:testng:6.9.5")
}
}
val a = assemble(jcommander) {
mavenJars {
assemble {
mavenJars {
}
jcenter {
publish = false
}
}
val j = jcenter(jcommander) {
publish = false
}
</pre>
<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>
<pre>
val packProject = packaging(project) {
packaging {
jar {
manifest {
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>
<pre>
val jc = jcenter(project) {
jcenter {
publish = true
}
</pre>

View file

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