1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt-doc.git synced 2025-04-25 03:57:11 -07:00
kobalt-doc/getting-started/index.html
2016-01-06 22:06:33 +04:00

153 lines
No EOL
6.5 KiB
HTML

<html>
<head>
<title>
Kobalt, by Cedric Beust
</title>
<script type="text/javascript" src="../sh/scripts/shCore.js"></script>
<script type="text/javascript" src="../sh/scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="../sh/scripts/shBrushJava.js"></script>
<script type="text/javascript" src="../sh/scripts/shBrushPlain.js"></script>
<script>
SyntaxHighlighter.defaults['gutter'] = false;
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
</script>
<!--[if lt IE 9]><script src="../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<!--
<script src="../bootstrap/assets/js/ie-emulation-modes-warning.js"></script>
-->
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Favicons -->
<!--
<link rel="icon" href="/favicon.ico">
-->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-238215-6', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div class="container">
<!-- Static navbar -->
<nav id="kobalt-navbar" class="navbar navbar-default">
</nav>
<div class="col-md-9">
<h2 class="section" id="downloading">1. Download Kobalt</h2>
<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>
<pre class="brush:plain">
cd $KOBALT_HOME
unzip kobalt-xxx.zip
</pre>
<h2 class="section" id="initialize">2. Initialize your project for Kobalt</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 there.
<li>Install the Kobalt Wrapper in your current directory (script `kobaltw`) and in the <code>kobalt/</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>
<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>
Here for example is the Build.kt for wasabi http framework
<pre class="brush:java">
import com.beust.kobalt.*
import com.beust.kobalt.plugin.packaging.assemble
import com.beust.kobalt.plugin.kotlin.*
val kotlin_version = "1.0.0-beta-4583"
val p = kotlinProject {
name = "wasabi"
group = "com.example"
artifactId = name
version = "0.1"
//tells Kobalt to also search here for dependencies
val repos = repos("http://oss.sonatype.org/content/repositories/snapshots")
dependencies {
compile("org.jetbrains.kotlin:kotlin-stdlib:" + kotlin_version,
"org.jetbrains.kotlin:kotlin-reflect:" + kotlin_version,
"com.fasterxml.jackson.core:jackson-core:2.6.4",
"com.fasterxml.jackson.core:jackson-databind:2.6.4",
"com.fasterxml.jackson.core:jackson-annotations:2.6.4",
"com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.6.3",
"com.fasterxml.woodstox:woodstox-core:5.0.1",
"io.netty:netty-all:4.0.31.Final",
"commons-codec:commons-codec:1.6",
"commons-logging:commons-logging:1.1.1",
"com.netflix.rxjava:rxjava-core:0.20.0-RC4",
"org.slf4j:slf4j-api:1.7.5",
"org.slf4j:slf4j-simple:1.7.5",
"joda-time:joda-time:2.3")
}
//these are only downloaded when running the test task
dependenciesTest {
compile("junit:junit:4.9",
"org.mockito:mockito-all:1.9.5",
"org.apache.httpcomponents:httpcore:4.3.3",
"org.apache.httpcomponents:httpclient:4.5.1")
}
//tells kobalt to produce a jar
assemble {
jar {
}
}
}
</pre>
<h2 class="section" id="idea-plugin">4. In Intellij IDEA, Sync Build File</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 loger get errors.
</p>
</div>
<!-- Table of contents -->
<div class="col-md-3" id="table-of-contents">
</div>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="../bootstrap/dist/js/bootstrap.min.js"></script>
<script src="../js/kobalt.js"></script>
<script>generateKobalt(1);</script>
<!--
<script src="../bootstrap/dist/js/docs.min.js"></script>
-->
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<!--
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
-->
</body>