forked from vert-x/vert-x.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradle_dev.html
162 lines (150 loc) · 8.59 KB
/
gradle_dev.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<!-- <link rel="stylesheet/less" href="bootstrap/less/bootstrap.less">
<script src="bootstrap/less/less-1.3.3.min.js"></script>
-->
<link href="bootstrap/bootstrap.css" type="text/css" rel="stylesheet"/>
<link href="google-code-prettify/prettify.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="google-code-prettify/prettify.js"></script>
<link href="css/vertx.css" type="text/css" rel="stylesheet"/>
<link href="css/sunburst.css" type="text/css" rel="stylesheet"/>
<title>Vert.x</title>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-30144458-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body onload="prettyPrint()" class="hp">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse"
data-target=".nav-collapse">
<span class="i-bar"></span>
<span class="i-bar"></span>
<span class="i-bar"></span>
</a>
<a class="brand" href="/">Vert.x</a>
<div class="nav-collapse">
<ul class="nav">
<li><a href="/">Home</a></li>
<li><a href="downloads.html">Download</a></li>
<li><a href="install.html">Install</a></li>
<li><a href="docs.html">Documentation</a></li>
<li><a href="examples.html">Examples</a></li>
<li><a href="community.html">Project Info</a></li>
<li><a href="https://github.com/vert-x/vert.x">Github</a></li>
<li><a href="http://modulereg.vertx.io/">Module Registry</a></li>
<li><a href="http://groups.google.com/group/vertx">Google Group</a></li>
<li><a href="http://vertxproject.wordpress.com/">Blog</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="span12">
<div class="well">
<h1>Developing Vert.x Modules with Gradle</h1>
</div>
</div>
</div>
<div class="row">
<div class="span12">
<div class="well">
<div>
<div class="toc">
<ul>
<li><a href="#developing-vertx-modules-with-gradle">Developing Vert.x modules with Gradle</a></li>
<li><a href="#clone-the-template-project">Clone the template project</a></li>
<li><a href="#outputs">Outputs</a></li>
<li><a href="#configuring-the-project">Configuring the project</a></li>
<li><a href="#overriding-default-vertx-configuration">Overriding default Vert.x configuration</a></li>
<li><a href="#other-useful-gradle-tasks">Other useful Gradle tasks</a></li>
<li><a href="#setup-your-ide">Setup your IDE</a></li>
<li><a href="#changing-the-dependencies-of-your-project">Changing the dependencies of your project</a></li>
<li><a href="#installing-your-module-in-maven-local">Installing your module in Maven local</a></li>
<li><a href="#pushing-your-module-to-maven">Pushing your module to Maven</a></li>
<li><a href="#registering-your-module-in-the-module-registry">Registering your module in the Module Registry</a></li>
<li><a href="#next-steps">Next steps</a></li>
</ul>
</div>
<h1 id="developing-vertx-modules-with-gradle">Developing Vert.x modules with Gradle</h1><br/>
<p>In this guide we'll show you how to develop a Vert.x project using Gradle.</p>
<h1 id="clone-the-template-project">Clone the template project</h1><br/>
<p>We provide a template <a href="https://github.com/vert-x/vertx-gradle-template">Gradle project</a> which you can clone to get you started.</p>
<p>Clone it locally</p>
<pre class="prettyprint">git clone https://github.com/vert-x/vertx-gradle-template.git my-vertx-module
</pre>
<p>Where <code>my-vertx-module</code> is the name you want to give your project.</p>
<p>Remove the origin</p>
<pre class="prettyprint">git remote rm origin
</pre>
<p>And add your new origin</p>
<pre class="prettyprint">git remote add origin <path to your repo>
</pre>
<p>Let's run the tests to make sure everything is working</p>
<pre class="prettyprint">cd my-vertx-module
./gradlew test
</pre>
<p>You should use the Gradle Wrapper (<code>./gradlew</code>) to run all Gradle tasks. You do not need to install Gradle manually. Take a look at <code>build.gradle</code> for a list of the available tasks.</p>
<h1 id="outputs">Outputs</h1><br/>
<p>The outputs of the project are:</p>
<ul>
<li>The Vert.x module zip file.</li>
<li>A jar that corresponds to the module will also be produced. This is useful when you have another project which depends on the classes from your module, as it allows you to add it as a standard Gradle build dependency in your other project.</li>
</ul>
<p>The outputs are created in the <code>build</code> directory as per normal.</p>
<h1 id="configuring-the-project">Configuring the project</h1><br/>
<p>You configure many things in <code>gradle.properties</code>:</p>
<ul>
<li>
<p><code>modowner</code>, <code>modname</code> and <code>version</code> determine the name of the module as described in the <a href="mods_manual.html#mod-id">modules manual</a></p>
</li>
<li>
<p><code>pullInDeps</code> determines whether all module dependencies should be packaged into the module as <a href="mods_manual.html#nested-mods">nested modules</a>. </p>
</li>
</ul>
<p>It also contains various properties used to configure versions of various dependencies.</p>
<h1 id="overriding-default-vertx-configuration">Overriding default Vert.x configuration</h1><br/>
<p>If you want to override any Vert.x platform configuration, e.g. <code>langs.properties</code>, <code>cluster.xml</code> or logging configuration, you can add those files to the directory <code>src/main/platform_lib</code> - these will then be added to the Vert.x platform classpath when you run the module with <code>./gradlew runMod</code></p>
<h1 id="other-useful-gradle-tasks">Other useful Gradle tasks</h1><br/>
<p>Open <code>build.gradle</code> and take a look at the comments there for a list of useful tasks supported by the build script.</p>
<h1 id="setup-your-ide">Setup your IDE</h1><br/>
<p>You can use the <code>idea</code> and <code>eclipse</code> Gradle plugins to create the project files for your IDE</p>
<pre class="prettyprint">./gradlew idea
</pre>
<p>Or</p>
<pre class="prettyprint">./gradlew eclipse
</pre>
<p>Once the IDE files have been created you can open the project files in your IDE.</p>
<p>Note: You can run the <code>idea</code> or <code>eclipse</code> tasks again if you change your project dependencies - in this way the IDE project files will be brought up-to-date.</p>
<p><em>You may have to tell your IDE to use Java source compatibility level of Java 7, as Gradle seems to default to Java 6 (!)</em></p>
<h1 id="changing-the-dependencies-of-your-project">Changing the dependencies of your project</h1><br/>
<p>If your project needs a third party jar to build and you want to include it in the <code>lib</code> directory of your module you can add the dependency in the <code>dependencies</code> section of <code>build.gradle</code> with a type of <code>compile</code>.</p>
<p>If you don't want it to be included in the <code>lib</code> directory you should add it as <code>provided</code>.</p>
<p>Once you've changed your dependencies just run <code>./gradlew idea</code> or <code>./gradlew eclipse</code> again to update your IDE project files with the new dependencies.</p>
<h1 id="installing-your-module-in-maven-local">Installing your module in Maven local</h1><br/>
<p>Use <code>./gradlew install</code> to install your module in your local Maven repository.</p>
<h1 id="pushing-your-module-to-maven">Pushing your module to Maven</h1><br/>
<p>Use <code>./gradlew uploadArchives</code> as normal to push your module to a Maven repository.</p>
<h1 id="registering-your-module-in-the-module-registry">Registering your module in the Module Registry</h1><br/>
<p>If you've pushed your module to a public Maven or Bintray repository you can register it in the <a href="http://modulereg.vertx.io">Module Registry</a> so others can search for and discover it.</p>
<h1 id="next-steps">Next steps</h1><br/>
<p>Now you've got the project all set-up and running, it's time to <a href="dev_guide.html">explore the standard project layout</a> itself.</p></div>
</div>
</div>
</div>
</div>
</body>
</html>