mirror of
https://github.com/ethauvin/kobalt-doc.git
synced 2025-04-25 03:57:11 -07:00
177 lines
7.1 KiB
HTML
177 lines
7.1 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="installing">1. Install Kobalt</h2>
|
|
<h3 class="section" indent="1" id="homebrew">With HomeBrew</h3>
|
|
<p>
|
|
If you are on MacOS and have <code>brew</code> installed:
|
|
<pre class="brush:plain">
|
|
$ brew install kobalt
|
|
$ which kobaltw
|
|
/usr/local/bin/brew</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> and unzip it in a directory that you can add to your <code>$PATH</code> variable:
|
|
</p>
|
|
<pre class="brush:plain">
|
|
cd yourLocation
|
|
unzip kobalt-xxx.zip
|
|
</pre>
|
|
<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
|
|
kobaltw --init java</pre>
|
|
to initialize a Java project, or
|
|
<pre class="brush:plain">
|
|
cd ~/java/project
|
|
kobaltw --init kotlin</pre>
|
|
<p>
|
|
to initialize a Kotlin project.
|
|
</p>
|
|
<div class="bs-callout bs-callout-warning">
|
|
<h4>Note</h4>
|
|
|
|
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 (this command is only useful for initializing projects).
|
|
</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.java.*
|
|
import com.beust.kobalt.plugin.packaging.*
|
|
import com.beust.kobalt.plugin.publish.*
|
|
|
|
val jcommander = project {
|
|
name = "jcommander"
|
|
group = "com.beust"
|
|
artifactId = name
|
|
version = "1.54"
|
|
|
|
dependenciesTest {
|
|
compile("org.testng:testng:6.9.9")
|
|
}
|
|
|
|
assemble {
|
|
mavenJars {
|
|
}
|
|
}
|
|
|
|
jcenter {
|
|
publish = true
|
|
}
|
|
}</pre>
|
|
<h2 class="section" id="build">4. Build your project</h2>
|
|
<p>
|
|
You can now attempt to build your project with Kobalt:
|
|
</p>
|
|
<pre class="brush:java">
|
|
./kobaltw assemble</pre>
|
|
<h2 class="section" id="idea-plugin">5. IDEA users: generate IDEA files</h2>
|
|
<p>
|
|
If you are planning to use IDEA to work on your project, you can ask Kobalt to generate all the IDEA files necessary to import your project:
|
|
</p>
|
|
<pre class="brush:java">
|
|
./kobaltw --init idea
|
|
</pre>
|
|
|
|
<div class="bs-callout bs-callout-warning">
|
|
<h4>Note</h4>
|
|
|
|
You need to have a valid <code>Build.kt</code> file for this command to work.
|
|
</div>
|
|
<p>
|
|
This will generate several files depending on the content of your build file. You can then launch IDEA and open this project directly.
|
|
</p>
|
|
<h2 class="section" id="idea-plugin">6. IDEA users: sync your 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>. Once the build file is synchronized, the errors should disappear
|
|
and you can now use all the regular functions of IDEA on <code>Build.kt</code> just like any other Kotlin
|
|
files (auto completion, jump to symbol, etc...).
|
|
</p>
|
|
|
|
<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>
|
|
|
|
</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>
|