Skip to content

Commit 61b5baa

Browse files
author
R. Tyler Croy
committed
Add basic gradle plumbing and tooling to build a thing in Java
1 parent d1e155e commit 61b5baa

File tree

4 files changed

+395
-0
lines changed

4 files changed

+395
-0
lines changed

HACKING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Hacking Metrics Wizard
2+
3+
4+
## General Design
5+
6+

build.gradle

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
plugins {
2+
id "java"
3+
id "checkstyle"
4+
id "findbugs"
5+
id "pmd"
6+
id "com.jfrog.bintray" version "1.1"
7+
}
8+
9+
//////////////////////////////////////////////////////
10+
// BUILD META-DATA
11+
group = 'com.github.lookout'
12+
version = '0.0.1'
13+
description = 'Metrics monitoring agent'
14+
/* Ensure we're at least JDK6 bttecode compatible */
15+
targetCompatibility = '1.6'
16+
sourceCompatibility = '1.6'
17+
//////////////////////////////////////////////////////
18+
19+
20+
//////////////////////////////////////////////////////
21+
// DEPENDENCY MANAGEMENT
22+
repositories {
23+
jcenter()
24+
}
25+
26+
dependencies {
27+
compile '
28+
compile "io.dropwizard.metrics:metrics-core:3.1.0"
29+
30+
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
31+
testCompile 'cglib:cglib-nodep:2.2.+'
32+
}
33+
//////////////////////////////////////////////////////
34+
35+
36+
//////////////////////////////////////////////////////
37+
// TESTS
38+
test {
39+
testLogging {
40+
/* we want more test failure information, see:
41+
* <http://mrhaki.blogspot.com/2013/05/gradle-goodness-show-more-information.html>
42+
*/
43+
exceptionFormat = 'full'
44+
events "passed", "skipped", "failed", "standardOut", "standardError"
45+
}
46+
}
47+
48+
/* We should always run tests before creating an artifact */
49+
assemble.dependsOn check
50+
//////////////////////////////////////////////////////
51+
52+
53+
//////////////////////////////////////////////////////
54+
// PUBLISHING
55+
56+
/* Add the sources jar to the list of artifacts to publish */
57+
task sourcesJar(type: Jar, dependsOn: classes) {
58+
classifier = 'sources'
59+
from sourceSets.main.allSource
60+
}
61+
62+
task javadocJar(type: Jar, dependsOn: javadoc) {
63+
classifier = 'javadoc'
64+
from javadoc.destinationDir
65+
}
66+
67+
artifacts {
68+
archives sourcesJar
69+
archives javadocJar
70+
}
71+
//////////////////////////////////////////////////////

config/checkstyle/checkstyle.xml

Lines changed: 315 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,315 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
5+
6+
<!-- This is a checkstyle configuration file. For descriptions of
7+
what the following rules do, please see the checkstyle configuration
8+
page at http://checkstyle.sourceforge.net/config.html -->
9+
10+
<module name="Checker">
11+
12+
<module name="FileTabCharacter">
13+
<!-- Checks that there are no tab characters in the file.
14+
-->
15+
</module>
16+
17+
<module name="NewlineAtEndOfFile"/>
18+
19+
<module name="RegexpSingleline">
20+
<!-- Checks that FIXME is not used in comments. TODO is preferred.
21+
-->
22+
<property name="format" value="((//.*)|(\*.*))FIXME" />
23+
<property name="message" value='TODO is preferred to FIXME. e.g. "TODO(johndoe): Refactor when v2 is released."' />
24+
</module>
25+
26+
<module name="RegexpSingleline">
27+
<!-- Checks that TODOs are named. (Actually, just that they are followed
28+
by an open paren.)
29+
-->
30+
<property name="format" value="((//.*)|(\*.*))TODO[^(]" />
31+
<property name="message" value='All TODOs should be named. e.g. "TODO(johndoe): Refactor when v2 is released."' />
32+
</module>
33+
34+
<!-- All Java AST specific tests live under TreeWalker module. -->
35+
<module name="TreeWalker">
36+
37+
<!--
38+
39+
IMPORT CHECKS
40+
41+
-->
42+
43+
<module name="RedundantImport">
44+
<!-- Checks for redundant import statements. -->
45+
<property name="severity" value="error"/>
46+
</module>
47+
48+
<module name="ImportOrder">
49+
<!-- Checks for out of order import statements. -->
50+
51+
<property name="severity" value="warning"/>
52+
<property name="groups" value="com.google,android,junit,net,org,java,javax"/>
53+
<!-- This ensures that static imports go first. -->
54+
<property name="option" value="top"/>
55+
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
56+
</module>
57+
58+
<!--
59+
60+
JAVADOC CHECKS
61+
62+
-->
63+
64+
<!-- Checks for Javadoc comments. -->
65+
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
66+
<module name="JavadocMethod">
67+
<property name="scope" value="protected"/>
68+
<property name="severity" value="warning"/>
69+
<property name="allowMissingJavadoc" value="true"/>
70+
<property name="allowMissingParamTags" value="true"/>
71+
<property name="allowMissingReturnTag" value="true"/>
72+
<property name="allowMissingThrowsTags" value="true"/>
73+
<property name="allowThrowsTagsForSubclasses" value="true"/>
74+
<property name="allowUndeclaredRTE" value="true"/>
75+
</module>
76+
77+
<module name="JavadocType">
78+
<property name="scope" value="protected"/>
79+
<property name="severity" value="error"/>
80+
</module>
81+
82+
<module name="JavadocStyle">
83+
<property name="severity" value="warning"/>
84+
</module>
85+
86+
<!--
87+
88+
NAMING CHECKS
89+
90+
-->
91+
92+
<!-- Item 38 - Adhere to generally accepted naming conventions -->
93+
94+
<module name="PackageName">
95+
<!-- Validates identifiers for package names against the
96+
supplied expression. -->
97+
<!-- Here the default checkstyle rule restricts package name parts to
98+
seven characters, this is not in line with common practice at Google.
99+
-->
100+
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
101+
<property name="severity" value="warning"/>
102+
</module>
103+
104+
<module name="TypeNameCheck">
105+
<!-- Validates static, final fields against the
106+
expression "^[A-Z][a-zA-Z0-9]*$". -->
107+
<metadata name="altname" value="TypeName"/>
108+
<property name="severity" value="warning"/>
109+
</module>
110+
111+
<module name="ConstantNameCheck">
112+
<!-- Validates non-private, static, final fields against the supplied
113+
public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
114+
<metadata name="altname" value="ConstantName"/>
115+
<property name="applyToPublic" value="true"/>
116+
<property name="applyToProtected" value="true"/>
117+
<property name="applyToPackage" value="true"/>
118+
<property name="applyToPrivate" value="false"/>
119+
<property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
120+
<message key="name.invalidPattern"
121+
value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
122+
<property name="severity" value="warning"/>
123+
</module>
124+
125+
<module name="StaticVariableNameCheck">
126+
<!-- Validates static, non-final fields against the supplied
127+
expression "^[a-z][a-zA-Z0-9]*_?$". -->
128+
<metadata name="altname" value="StaticVariableName"/>
129+
<property name="applyToPublic" value="true"/>
130+
<property name="applyToProtected" value="true"/>
131+
<property name="applyToPackage" value="true"/>
132+
<property name="applyToPrivate" value="true"/>
133+
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
134+
<property name="severity" value="warning"/>
135+
</module>
136+
137+
<module name="MemberNameCheck">
138+
<!-- Validates non-static members against the supplied expression. -->
139+
<metadata name="altname" value="MemberName"/>
140+
<property name="applyToPublic" value="true"/>
141+
<property name="applyToProtected" value="true"/>
142+
<property name="applyToPackage" value="true"/>
143+
<property name="applyToPrivate" value="true"/>
144+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
145+
<property name="severity" value="warning"/>
146+
</module>
147+
148+
<module name="MethodNameCheck">
149+
<!-- Validates identifiers for method names. -->
150+
<metadata name="altname" value="MethodName"/>
151+
<property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
152+
<property name="severity" value="warning"/>
153+
</module>
154+
155+
<module name="ParameterName">
156+
<!-- Validates identifiers for method parameters against the
157+
expression "^[a-z][a-zA-Z0-9]*$". -->
158+
<property name="severity" value="warning"/>
159+
</module>
160+
161+
<module name="LocalFinalVariableName">
162+
<!-- Validates identifiers for local final variables against the
163+
expression "^[a-z][a-zA-Z0-9]*$". -->
164+
<property name="severity" value="warning"/>
165+
</module>
166+
167+
<module name="LocalVariableName">
168+
<!-- Validates identifiers for local variables against the
169+
expression "^[a-z][a-zA-Z0-9]*$". -->
170+
<property name="severity" value="warning"/>
171+
</module>
172+
173+
174+
<!--
175+
176+
LENGTH and CODING CHECKS
177+
178+
-->
179+
180+
<module name="LineLength">
181+
<!-- Checks if a line is too long. -->
182+
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="100"/>
183+
<property name="severity" value="error"/>
184+
185+
<!--
186+
The default ignore pattern exempts the following elements:
187+
- import statements
188+
- long URLs inside comments
189+
-->
190+
191+
<property name="ignorePattern"
192+
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
193+
default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)$"/>
194+
</module>
195+
196+
<module name="LeftCurly">
197+
<!-- Checks for placement of the left curly brace ('{'). -->
198+
<property name="severity" value="warning"/>
199+
</module>
200+
201+
<module name="RightCurly">
202+
<!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
203+
the same line. e.g., the following example is fine:
204+
<pre>
205+
if {
206+
...
207+
} else
208+
</pre>
209+
-->
210+
<!-- This next example is not fine:
211+
<pre>
212+
if {
213+
...
214+
}
215+
else
216+
</pre>
217+
-->
218+
<property name="option" value="same"/>
219+
<property name="severity" value="warning"/>
220+
</module>
221+
222+
<!-- Checks for braces around if and else blocks -->
223+
<module name="NeedBraces">
224+
<property name="severity" value="warning"/>
225+
<property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
226+
</module>
227+
228+
<module name="UpperEll">
229+
<!-- Checks that long constants are defined with an upper ell.-->
230+
<property name="severity" value="error"/>
231+
</module>
232+
233+
<module name="FallThrough">
234+
<!-- Warn about falling through to the next case statement. Similar to
235+
javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
236+
on the last non-blank line preceding the fallen-into case contains 'fall through' (or
237+
some other variants which we don't publicized to promote consistency).
238+
-->
239+
<property name="reliefPattern"
240+
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
241+
<property name="severity" value="error"/>
242+
</module>
243+
244+
245+
<!--
246+
247+
MODIFIERS CHECKS
248+
249+
-->
250+
251+
<module name="ModifierOrder">
252+
<!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
253+
8.4.3. The prescribed order is:
254+
public, protected, private, abstract, static, final, transient, volatile,
255+
synchronized, native, strictfp
256+
-->
257+
</module>
258+
259+
260+
<!--
261+
262+
WHITESPACE CHECKS
263+
264+
-->
265+
266+
<module name="WhitespaceAround">
267+
<!-- Checks that various tokens are surrounded by whitespace.
268+
This includes most binary operators and keywords followed
269+
by regular or curly braces.
270+
-->
271+
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
272+
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
273+
EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
274+
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
275+
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
276+
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
277+
SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
278+
<property name="severity" value="error"/>
279+
</module>
280+
281+
<module name="WhitespaceAfter">
282+
<!-- Checks that commas, semicolons and typecasts are followed by
283+
whitespace.
284+
-->
285+
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
286+
</module>
287+
288+
<module name="NoWhitespaceAfter">
289+
<!-- Checks that there is no whitespace after various unary operators.
290+
Linebreaks are allowed.
291+
-->
292+
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
293+
UNARY_PLUS"/>
294+
<property name="allowLineBreaks" value="true"/>
295+
<property name="severity" value="error"/>
296+
</module>
297+
298+
<module name="NoWhitespaceBefore">
299+
<!-- Checks that there is no whitespace before various unary operators.
300+
Linebreaks are allowed.
301+
-->
302+
<property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
303+
<property name="allowLineBreaks" value="true"/>
304+
<property name="severity" value="error"/>
305+
</module>
306+
307+
<module name="ParenPad">
308+
<!-- Checks that there is no whitespace before close parens or after
309+
open parens.
310+
-->
311+
<property name="severity" value="warning"/>
312+
</module>
313+
314+
</module>
315+
</module>

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
org.gradle.daemon=true
2+
bintrayUser=
3+
bintrayKey=

0 commit comments

Comments
 (0)