Skip to content

Commit 8829af9

Browse files
committed
setup Makefiles, dependencies and plugins
lombok, checkstyle, sonarqube, jacoco, ben-manes.versions
1 parent 5acc7a0 commit 8829af9

File tree

5 files changed

+344
-1
lines changed

5 files changed

+344
-1
lines changed

.github/workflows/build.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: SonarQube
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
jobs:
9+
build:
10+
name: Build and analyze
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16+
- name: Set up JDK 21
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: 21
20+
distribution: 'temurin' # Alternative distribution options are available
21+
- name: Build with Gradle
22+
uses: gradle/gradle-build-action@v3
23+
with:
24+
arguments: build
25+
build-root-directory: app
26+
- name: Generate coverage report
27+
run: make report
28+
- name: Cache SonarQube packages
29+
uses: actions/cache@v4
30+
with:
31+
path: app/.sonar/cache
32+
key: ${{ runner.os }}-sonar
33+
restore-keys: ${{ runner.os }}-sonar
34+
- name: Cache Gradle packages
35+
uses: actions/cache@v4
36+
with:
37+
path: app/.gradle/caches
38+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
39+
restore-keys: ${{ runner.os }}-gradle
40+
- name: sonar analyze
41+
env:
42+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
43+
run: ./gradlew sonar --info
44+
working-directory: ./app

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.DEFAULT_GOAL := build-run
2+
3+
clean:
4+
make -C app clean
5+
6+
build:
7+
make -C app build
8+
9+
install:
10+
make -C app install
11+
12+
run-dist:
13+
make -C run-dist
14+
15+
run:
16+
make -C app run
17+
18+
test:
19+
make -C app test
20+
21+
report:
22+
make -C app report
23+
24+
lint:
25+
make -C app lint
26+
27+
update-deps:
28+
make -C app update-deps
29+
30+
31+
build-run: build run
32+
33+
.PHONY: build

app/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.DEFAULT_GOAL := build-run
2+
3+
run-dist:
4+
./build/install/app/bin/app ${ARGS}
5+
6+
setup:
7+
./gradlew wrapper --gradle-version 8.5
8+
9+
clean:
10+
./gradlew clean
11+
12+
build:
13+
./gradlew clean build
14+
15+
install:
16+
./gradlew clean install
17+
18+
install-dist:
19+
./gradlew clean installDist
20+
21+
run:
22+
./gradlew run
23+
24+
test:
25+
./gradlew test
26+
27+
report:
28+
./gradlew test jacocoTestReport
29+
30+
lint:
31+
./gradlew checkstyleMain checkstyleTest
32+
33+
check-deps:
34+
./gradlew dependencyUpdates -Drevision=release
35+
36+
37+
build-run: build run
38+
39+
.PHONY: build

app/build.gradle.kts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
plugins {
22
id("java")
3+
checkstyle
4+
jacoco
5+
id("org.sonarqube") version "6.1.0.5360"
6+
id("com.github.ben-manes.versions") version "0.52.0"
37
}
48

59
group = "hexlet.code"
@@ -10,10 +14,28 @@ repositories {
1014
}
1115

1216
dependencies {
13-
testImplementation(platform("org.junit:junit-bom:5.10.0"))
17+
testImplementation(platform("org.junit:junit-bom:5.11.4"))
1418
testImplementation("org.junit.jupiter:junit-jupiter")
19+
compileOnly("org.projectlombok:lombok:1.18.36")
20+
annotationProcessor("org.projectlombok:lombok:1.18.36")
1521
}
1622

1723
tasks.test {
1824
useJUnitPlatform()
25+
finalizedBy("jacocoTestReport")
26+
}
27+
28+
tasks.jacocoTestReport {
29+
reports {
30+
dependsOn(tasks.test)
31+
xml.required.set(true)
32+
}
33+
}
34+
35+
sonar {
36+
properties {
37+
property("sonar.projectKey", "prvmjsky_java-project-72")
38+
property("sonar.organization", "prvmjsky")
39+
property("sonar.host.url", "https://sonarcloud.io")
40+
}
1941
}
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<!--
7+
8+
Checkstyle configuration that checks the sun coding conventions from:
9+
10+
- the Java Language Specification at
11+
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
12+
13+
- the Sun Code Conventions at https://www.oracle.com/technetwork/java/codeconvtoc-136057.html
14+
15+
- the Javadoc guidelines at
16+
https://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
17+
18+
- the JDK Api documentation https://docs.oracle.com/en/java/javase/11/
19+
20+
- some best practices
21+
22+
Checkstyle is very configurable. Be sure to read the documentation at
23+
https://checkstyle.org (or in your downloaded distribution).
24+
25+
Most Checks are configurable, be sure to consult the documentation.
26+
27+
To completely disable a check, just comment it out or delete it from the file.
28+
To suppress certain violations please review suppression filters.
29+
30+
Finally, it is worth reading the documentation.
31+
32+
-->
33+
34+
<module name="Checker">
35+
<!--
36+
If you set the basedir property below, then all reported file
37+
names will be relative to the specified directory. See
38+
https://checkstyle.org/5.x/config.html#Checker
39+
40+
<property name="basedir" value="${basedir}"/>
41+
-->
42+
<property name="severity" value="error"/>
43+
44+
<property name="fileExtensions" value="java, properties, xml"/>
45+
46+
<!-- Excludes all 'module-info.java' files -->
47+
<!-- See https://checkstyle.org/config_filefilters.html -->
48+
<module name="BeforeExecutionExclusionFileFilter">
49+
<property name="fileNamePattern" value="module\-info\.java$"/>
50+
</module>
51+
52+
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
53+
<module name="SuppressionFilter">
54+
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}"
55+
default="checkstyle-suppressions.xml" />
56+
<property name="optional" value="true"/>
57+
</module>
58+
59+
<!-- Checks that a package-info.java file exists for each package. -->
60+
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
61+
<!-- <module name="JavadocPackage"/> -->
62+
63+
<!-- Checks whether files end with a new line. -->
64+
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
65+
<module name="NewlineAtEndOfFile"/>
66+
67+
<!-- Checks that property files contain the same keys. -->
68+
<!-- See https://checkstyle.org/config_misc.html#Translation -->
69+
<module name="Translation"/>
70+
71+
<!-- Checks for Size Violations. -->
72+
<!-- See https://checkstyle.org/config_sizes.html -->
73+
<module name="FileLength"/>
74+
<module name="LineLength">
75+
<property name="fileExtensions" value="java"/>
76+
<property name="max" value="120"/>
77+
</module>
78+
79+
<!-- Checks for whitespace -->
80+
<!-- See https://checkstyle.org/config_whitespace.html -->
81+
<module name="FileTabCharacter"/>
82+
83+
<!-- Miscellaneous other checks. -->
84+
<!-- See https://checkstyle.org/config_misc.html -->
85+
<module name="RegexpSingleline">
86+
<property name="format" value="\s+$"/>
87+
<property name="minimum" value="0"/>
88+
<property name="maximum" value="0"/>
89+
<property name="message" value="Line has trailing spaces."/>
90+
</module>
91+
92+
<!-- Checks for Headers -->
93+
<!-- See https://checkstyle.org/config_header.html -->
94+
<!-- <module name="Header"> -->
95+
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
96+
<!-- <property name="fileExtensions" value="java"/> -->
97+
<!-- </module> -->
98+
99+
<module name="TreeWalker">
100+
101+
<!-- Checks for Javadoc comments. -->
102+
<!-- See https://checkstyle.org/config_javadoc.html -->
103+
<module name="InvalidJavadocPosition"/>
104+
<module name="JavadocMethod"/>
105+
<module name="JavadocType"/>
106+
<!-- <module name="JavadocVariable"/> -->
107+
<module name="JavadocStyle"/>
108+
<!-- <module name="MissingJavadocMethod"/> -->
109+
110+
<!-- Checks for Naming Conventions. -->
111+
<!-- See https://checkstyle.org/config_naming.html -->
112+
<module name="ConstantName"/>
113+
<module name="LocalFinalVariableName"/>
114+
<module name="LocalVariableName"/>
115+
<module name="MemberName"/>
116+
<module name="MethodName"/>
117+
<module name="PackageName"/>
118+
<module name="ParameterName"/>
119+
<module name="StaticVariableName"/>
120+
<module name="TypeName"/>
121+
122+
<!-- Checks for imports -->
123+
<!-- See https://checkstyle.org/config_import.html -->
124+
<module name="AvoidStarImport"/>
125+
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
126+
<module name="RedundantImport"/>
127+
<module name="UnusedImports">
128+
<property name="processJavadoc" value="false"/>
129+
</module>
130+
131+
<!-- Checks for Size Violations. -->
132+
<!-- See https://checkstyle.org/config_sizes.html -->
133+
<module name="MethodLength"/>
134+
<module name="ParameterNumber"/>
135+
136+
<!-- Checks for whitespace -->
137+
<!-- See https://checkstyle.org/config_whitespace.html -->
138+
<module name="EmptyForIteratorPad"/>
139+
<module name="GenericWhitespace"/>
140+
<module name="MethodParamPad"/>
141+
<module name="NoWhitespaceAfter"/>
142+
<module name="NoWhitespaceBefore"/>
143+
<module name="OperatorWrap"/>
144+
<module name="ParenPad"/>
145+
<module name="TypecastParenPad"/>
146+
<module name="WhitespaceAfter"/>
147+
<module name="WhitespaceAround"/>
148+
149+
<!-- Modifier Checks -->
150+
<!-- See https://checkstyle.org/config_modifiers.html -->
151+
<module name="ModifierOrder"/>
152+
<module name="RedundantModifier"/>
153+
154+
<!-- Checks for blocks. You know, those {}'s -->
155+
<!-- See https://checkstyle.org/config_blocks.html -->
156+
<module name="AvoidNestedBlocks"/>
157+
<module name="EmptyBlock"/>
158+
<module name="LeftCurly"/>
159+
<module name="NeedBraces"/>
160+
<module name="RightCurly"/>
161+
162+
<!-- Checks for common coding problems -->
163+
<!-- See https://checkstyle.org/config_coding.html -->
164+
<module name="EmptyStatement"/>
165+
<module name="EqualsHashCode"/>
166+
<!-- <module name="HiddenField"/> -->
167+
<module name="IllegalInstantiation"/>
168+
<module name="InnerAssignment"/>
169+
<!-- <module name="MagicNumber"/> -->
170+
<module name="MissingSwitchDefault"/>
171+
<module name="MultipleVariableDeclarations"/>
172+
<module name="SimplifyBooleanExpression"/>
173+
<module name="SimplifyBooleanReturn"/>
174+
175+
<!-- Checks for class design -->
176+
<!-- See https://checkstyle.org/config_design.html -->
177+
<module name="DesignForExtension"/>
178+
<module name="FinalClass"/>
179+
<!-- <module name="HideUtilityClassConstructor"/> -->
180+
<module name="InterfaceIsType"/>
181+
<!-- <module name = "VisibilityModifier">
182+
<property name="protectedAllowed" value="true" />
183+
</module> -->
184+
185+
<!-- Miscellaneous other checks. -->
186+
<!-- See https://checkstyle.org/config_misc.html -->
187+
<module name="ArrayTypeStyle"/>
188+
<!-- <module name="FinalParameters"/> -->
189+
<!-- <module name="TodoComment"/> -->
190+
<module name="UpperEll"/>
191+
192+
<module name="Indentation">
193+
<property name="basicOffset" value="4"/>
194+
</module>
195+
196+
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
197+
<module name="SuppressionXpathFilter">
198+
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}"
199+
default="checkstyle-xpath-suppressions.xml" />
200+
<property name="optional" value="true"/>
201+
</module>
202+
203+
</module>
204+
205+
</module>

0 commit comments

Comments
 (0)