mirror of
https://github.com/ethauvin/kobalt-doc.git
synced 2025-04-25 12:07:10 -07:00
Merge from upstream.
This commit is contained in:
commit
b4cf88c58d
11 changed files with 950 additions and 498 deletions
|
@ -40,97 +40,109 @@
|
|||
<nav id="kobalt-navbar" class="navbar navbar-default">
|
||||
</nav>
|
||||
<div class="col-md-9">
|
||||
<h2 class="section" id="downloading">1. Download Kobalt</h2>
|
||||
<h2 class="section" id="installing">1. Install Kobalt</h2>
|
||||
<h3 class="section" indent="1" id="homebrew">With HomeBrew</h3>
|
||||
<p>
|
||||
<a href="https://github.com/cbeust/kobalt/releases/latest">Download the zip file</a> then unzip it in a location we'll call <code>KOBALT_HOME</code>:
|
||||
</p>
|
||||
If you are on MacOS and have <code>brew</code> installed:
|
||||
<pre class="brush:plain">
|
||||
cd $KOBALT_HOME
|
||||
$ brew install kobalt
|
||||
$ which kobaltw
|
||||
/usr/local/bin/kobaltw</pre>
|
||||
</p>
|
||||
<h3 class="section" indent="1" id="manually">Manually</h3>
|
||||
<p>
|
||||
<a href="https://github.com/cbeust/kobalt/releases/latest">Download the zip file</a>, unzip it and add the <code>bin</code> directory to your <code>$PATH</code> variable so that you can invoke the command <code>kobaltw</code>:
|
||||
</p>
|
||||
<pre class="brush:plain">
|
||||
cd yourLocation
|
||||
unzip kobalt-xxx.zip
|
||||
cd kobalt-xxx
|
||||
export PATH=$PWD/bin:$PATH
|
||||
</pre>
|
||||
<p>
|
||||
<em>Note: Kobalt doesn't need any environment variable to run, the environment variable used above
|
||||
is only here for clarity.</em>
|
||||
</p>
|
||||
<h2 class="section" id="initialize">2. Initialize your project</h2>
|
||||
<p>
|
||||
Change to your project directory and call the <code>kobaltw</code> command with <code>--init</code>:
|
||||
</p>
|
||||
<h2 class="section" id="initialize">2. Initialize your project</h2>
|
||||
<p>
|
||||
Change to your project directory and call the <code>kobaltw</code> command with <code>--init</code>:
|
||||
</p>
|
||||
<pre class="brush:plain">
|
||||
cd ~/java/project
|
||||
$KOBALT_HOME/kobaltw --init
|
||||
</pre>
|
||||
<p>
|
||||
This command will do two things:
|
||||
</p>
|
||||
<ol>
|
||||
<li>Create a default <code>kobalt/src/Build.kt</code> file based on what was found in your 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>.
|
||||
</ol>
|
||||
<p>
|
||||
You can now attempt to build your project with Kobalt:
|
||||
</p>
|
||||
kobaltw --init java</pre>
|
||||
to initialize a Java project, or
|
||||
<pre class="brush:plain">
|
||||
./kobaltw assemble
|
||||
</pre>
|
||||
If your project follows a regular build structure (e.g. <a href="https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html">Maven's hierarchy</a>), this should compile your file and create a .jar file. If not, you will have to make a few edits to your <code>Build.kt</code>.
|
||||
As of this writing, Kobalt supports Java and Kotlin projects.
|
||||
|
||||
<h2 class="section" id="edit">3. Edit kobalt/src/Build.kt</h2>
|
||||
cd ~/java/project
|
||||
kobaltw --init kotlin</pre>
|
||||
<p>
|
||||
to initialize a Kotlin project.
|
||||
</p>
|
||||
<div class="bs-callout bs-callout-warning">
|
||||
<h4>Note</h4>
|
||||
|
||||
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>:
|
||||
Kobalt supports projects with both Kotlin and Java sources. For such projects,
|
||||
use either <code>java</code> or <code>kotlin</code> as the <code>--init</code> argument and refer to the <a href="../plug-ins/index.html#mixed-projects">mixed projects documentation</a> for more details.
|
||||
</div>
|
||||
<p>
|
||||
This command will do two things:
|
||||
</p>
|
||||
<ol>
|
||||
<li>Create a default <code>kobalt/src/Build.kt</code> file based on what was found in your project.</li>
|
||||
<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.</li>
|
||||
</ol>
|
||||
<p>
|
||||
From now on, you can just use <code>./kobaltw</code> to build and you can ignore the <code>kobaltw</code> on your path, which is only useful to install Kobalt on new projects. Since you will now build each project with its own <code>./kobaltw</code> command, they will use their own version of Kobalt.
|
||||
</p>
|
||||
<h2 class="section" id="edit">3. Edit kobalt/src/Build.kt</h2>
|
||||
|
||||
<p>
|
||||
If your project uses a standard folder structure, you can skip this section and try to build your project directly.
|
||||
</p>
|
||||
<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">
|
||||
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:")
|
||||
}
|
||||
|
||||
// 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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h2 class="section" id="idea-plugin">4. Sync your build file</h2>
|
||||
jcenter {
|
||||
publish = true
|
||||
}
|
||||
}</pre>
|
||||
<h2 class="section" id="build">4. Build your project</h2>
|
||||
<p>
|
||||
If you're using Intellij IDEA, make sure you've <a href="../idea-plug-in/index.html">installed the Kobalt plugin</a> and then go to <code>Kobalt -> Sync Build File</code>. This will download dependencies in a way that IDEA understand so you no longer get errors.
|
||||
You can now attempt to build your project with Kobalt:
|
||||
</p>
|
||||
<pre class="brush:java">
|
||||
./kobaltw assemble</pre>
|
||||
<h2 class="section" id="import-in-idea">5. IDEA users: Import your project in IDEA</h2>
|
||||
<p>
|
||||
|
||||
<p>
|
||||
You can now open your project in IDEA and if you have the Kobalt IDEA plug-in installed, you
|
||||
will be asked whether you want to import that project as a Kobalt project.
|
||||
</p>
|
||||
<h2 class="section" id="idea-plugin">6. IDEA users: Sync your build file</h2>
|
||||
<p>
|
||||
Once your project has been imported as a Kobalt project in IDEA, bring up the Kobalt window (sideways on the
|
||||
right side) and click the Sync icon, which will synchronize your build file with IDEA.
|
||||
</p>
|
||||
|
||||
<h2 class="section" id="next-steps">5. Next steps</h2>
|
||||
<h2 class="section" id="next-steps">7. Next steps</h2>
|
||||
<p>
|
||||
From this point, you can either <a href="../idea-plug-in/index.html">learn how to install the Kobalt IDEA plug-in</a> or read <a href="../documentation/index.html">Kobalt's documentation</a>.
|
||||
</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue