Skip to content

Commit ce2521d

Browse files
weisJMarko Radosavljević
authored and
Marko Radosavljević
committedSep 30, 2020
Convert gradle script from groovy to kotlin.
Add bom to manage dependency version. Use consistent file encoding in build.gradle.kts and .editorconfig
1 parent 76ad6a4 commit ce2521d

19 files changed

+244
-1664
lines changed
 

‎.editorconfig

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
root = true
22

33
[*]
4-
end_of_line = lf
54
insert_final_newline = true
65
trim_trailing_whitespace = true
76
charset = utf-8
@@ -10,3 +9,22 @@ indent_size = 4
109

1110
[*.yml]
1211
indent_size = 2
12+
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[{*.sh, gradlew}]
18+
end_of_line = lf
19+
20+
[{*.bat, *.cmd}]
21+
end_of_line = crlf
22+
23+
[{*.kts, *.kt}]
24+
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
25+
ij_kotlin_name_count_to_use_star_import = 999
26+
ij_kotlin_name_count_to_use_star_import_for_members = 999
27+
28+
[*.java]
29+
# Doc: https://youtrack.jetbrains.com/issue/IDEA-170643#focus=streamItem-27-3708697.0-0
30+
max_line_length = 120

‎.gitattributes

+24-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
*.bat text eol=crlf
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
*.java text
5+
*.html text
6+
*.css text
7+
*.js text
8+
*.sql text
9+
*.q text
10+
11+
*.sh text eol=lf
12+
*.cgi text eol=lf
13+
14+
*.bat text eol=crlf
15+
*.cmd text eol=crlf
16+
17+
# Images are explicitly configured as binary, just in case
18+
*.gif binary
19+
*.jpg binary
20+
*.jpeg binary
21+
*.png binary
22+
23+
# Below files don't have extension, so we mention them explicitly
24+
/gradlew text eol=lf

‎build.gradle

-74
This file was deleted.

‎build.gradle.kts

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
plugins {
2+
`java-library`
3+
application
4+
id("org.beryx.runtime")
5+
}
6+
7+
val String.v: String get() = rootProject.extra["$this.version"] as String
8+
val projectVersion = "MyLibreLab".v
9+
10+
dependencies {
11+
implementation("com.google.guava:guava:28.2-jre")
12+
implementation("javax.vecmath:vecmath")
13+
implementation("eu.hansolo:SteelSeries")
14+
implementation("org.pushing-pixels:trident")
15+
implementation("org.json:json")
16+
implementation("net.java.dev.jna:jna-platform")
17+
implementation("org.scream3r:jssc")
18+
implementation("org.bidib.jbidib:bidib-rxtx-binaries")
19+
20+
implementation("com.pi4j:pi4j-core")
21+
implementation("com.pi4j:pi4j-device")
22+
implementation("com.pi4j:pi4j-gpio-extension")
23+
implementation("com.pi4j:pi4j-service")
24+
25+
implementation("javax.xml.bind:jaxb-api")
26+
implementation("com.sun.xml.bind:jaxb-core")
27+
implementation("com.sun.xml.bind:jaxb-impl")
28+
29+
implementation("org.tinylog:tinylog-api")
30+
implementation("org.tinylog:tinylog-impl")
31+
32+
implementation("org.netbeans.external:AbsoluteLayout")
33+
implementation("org.swinglabs:swing-layout")
34+
35+
testImplementation("org.junit.jupiter:junit-jupiter-api")
36+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
37+
38+
39+
// implementation("org.netbeans.external:swing-layout-1.0.4:RELEASE68")
40+
// implementation fileTree(dir: "distribution/lib", include: ["*.jar])
41+
// implementation fileTree(dir: "distribution/lib_win_64", include: ["*.jar"])
42+
// implementation fileTree(dir: "jssc", include: ["*.jar"])
43+
// implementation fileTree(dir: "pi4j-1.0", include: ["*.jar"])
44+
}
45+
46+
application {
47+
mainClassName = "VisualLogic.FrameMain"
48+
}
49+
50+
runtime {
51+
addOptions(
52+
"--strip-debug",
53+
"--compress", "2",
54+
"--no-header-files",
55+
"--no-man-pages"
56+
)
57+
}
58+
59+
allprojects {
60+
version = projectVersion
61+
62+
repositories {
63+
mavenCentral()
64+
}
65+
66+
plugins.withType<JavaLibraryPlugin> {
67+
dependencies {
68+
"api"(platform(project(":mylibrelab-dependencies-bom")))
69+
"annotationProcessor"(platform(project(":mylibrelab-dependencies-bom")))
70+
}
71+
72+
configure<JavaPluginExtension> {
73+
sourceCompatibility = JavaVersion.VERSION_11
74+
targetCompatibility = JavaVersion.VERSION_11
75+
}
76+
77+
tasks {
78+
withType<JavaCompile> {
79+
options.encoding = "UTF-8"
80+
}
81+
withType<Test> {
82+
// Use junit platform for unit tests
83+
useJUnitPlatform()
84+
}
85+
}
86+
}
87+
}

‎dependencies-bom/build.gradle.kts

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
plugins {
2+
`java-platform`
3+
}
4+
5+
val String.v: String get() = rootProject.extra["$this.version"] as String
6+
7+
// Note: Gradle allows to declare dependency on "bom" as "api",
8+
// and it makes the constraints to be transitively visible
9+
// However Maven can't express that, so the approach is to use Gradle resolution
10+
// and generate pom files with resolved versions
11+
// See https://github.com/gradle/gradle/issues/9866
12+
13+
fun DependencyConstraintHandlerScope.apiv(
14+
notation: String,
15+
versionProp: String = notation.substringAfterLast(':')
16+
) =
17+
"api"("$notation:${versionProp.v}")
18+
19+
fun DependencyConstraintHandlerScope.runtimev(
20+
notation: String,
21+
versionProp: String = notation.substringAfterLast(':')
22+
) =
23+
"runtimeOnly"("$notation:${versionProp.v}")
24+
25+
dependencies {
26+
// Parenthesis are needed here: https://github.com/gradle/gradle/issues/9248
27+
(constraints) {
28+
// api means "the dependency is for both compilation and runtime"
29+
// runtime means "the dependency is only for runtime, not for compilation"
30+
// In other words, marking dependency as "runtime" would avoid accidental
31+
// dependency on it during compilation
32+
apiv("com.google.guava:guava")
33+
apiv("javax.vecmath:vecmath")
34+
apiv("eu.hansolo:SteelSeries")
35+
apiv("org.pushing-pixels:trident")
36+
apiv("org.json:json")
37+
apiv("net.java.dev.jna:jna-platform", "jna")
38+
apiv("org.scream3r:jssc")
39+
apiv("org.bidib.jbidib:bidib-rxtx-binaries", "bidib-rxtx")
40+
41+
apiv("org.netbeans.external:AbsoluteLayout")
42+
apiv("org.swinglabs:swing-layout")
43+
44+
apiv("com.pi4j:pi4j-core", "pi4j")
45+
apiv("com.pi4j:pi4j-device", "pi4j")
46+
apiv("com.pi4j:pi4j-gpio-extension", "pi4j")
47+
apiv("com.pi4j:pi4j-service", "pi4j")
48+
49+
apiv("javax.xml.bind:jaxb-api", "jaxb")
50+
apiv("com.sun.xml.bind:jaxb-core", "jaxb")
51+
apiv("com.sun.xml.bind:jaxb-impl", "jaxb")
52+
53+
apiv("org.tinylog:tinylog-api", "tinylog")
54+
apiv("org.tinylog:tinylog-impl", "tinylog")
55+
56+
apiv("org.junit.jupiter:junit-jupiter-api", "junit")
57+
apiv("org.junit.jupiter:junit-jupiter-engine", "junit")
58+
}
59+
}

‎elements/FrontElements/2Boolean/Indicator_JV/build.xml

-73
This file was deleted.

‎elements/FrontElements/2Boolean/Indicator_JV/definition.def

-8
This file was deleted.

‎elements/FrontElements/2Boolean/Indicator_JV/manifest.mf

-3
This file was deleted.

‎elements/FrontElements/2Numerisch/Linear_JV/nbproject/build-impl.xml

-1,403
This file was deleted.

‎elements/FrontElements/2Numerisch/Linear_JV/nbproject/genfiles.properties

-8
This file was deleted.

‎elements/FrontElements/2Numerisch/Linear_JV/nbproject/project.properties

-78
This file was deleted.

‎elements/FrontElements/2Numerisch/Linear_JV/nbproject/project.xml

-13
This file was deleted.

‎gradle.properties

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# suppress inspection "UnusedProperty" for whole file
2+
org.gradle.parallel = true
3+
kotlin.code.style = official
4+
5+
# See https://github.com/gradle/gradle/pull/11358 , https://issues.apache.org/jira/browse/INFRA-14923
6+
# repository.apache.org does not yet support .sha256 and .sha512 checksums
7+
systemProp.org.gradle.internal.publish.checksums.insecure = true
8+
9+
# Darklaf version
10+
MyLibreLab.version = 0.1.0
11+
12+
# Plugins
13+
org.beryx.runtime.version = 1.8.1
14+
15+
# Dependencies
16+
guava.version = 28.2-jre
17+
vecmath.version = 1.5.2
18+
SteelSeries.version = 3.9.13
19+
trident.version = 1.2
20+
json.version = 20140107
21+
jna.version = 4.2.2
22+
jssc.version = 2.8.0
23+
bidib-rxtx.version = 2.2
24+
pi4j.version = 1.1
25+
jaxb.version = 2.3.0
26+
tinylog.version = 2.1.1
27+
AbsoluteLayout.version = RELEASE113
28+
swing-layout.version = 1.0.3
29+
junit.version = 5.6.0

‎gradle/wrapper/gradle-wrapper.jar

216 Bytes
Binary file not shown.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

‎gradlew

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ esac
8282

8383
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
8484

85+
8586
# Determine the Java command to use to start the JVM.
8687
if [ -n "$JAVA_HOME" ] ; then
8788
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -129,6 +130,7 @@ fi
129130
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130131
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131132
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133+
132134
JAVACMD=`cygpath --unix "$JAVACMD"`
133135

134136
# We build the pattern for arguments to be converted via cygpath

‎gradlew.bat

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%*
8484

8585
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
8686

87+
8788
@rem Execute Gradle
8889
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
8990

‎settings.gradle

-1
This file was deleted.

‎settings.gradle.kts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pluginManagement {
2+
plugins {
3+
fun String.v() = extra["$this.version"].toString()
4+
fun PluginDependenciesSpec.idv(id: String, key: String = id) = id(id) version key.v()
5+
6+
idv("org.beryx.runtime")
7+
}
8+
}
9+
10+
rootProject.name = "MyLibreLab"
11+
12+
include(
13+
"dependencies-bom"
14+
)
15+
16+
for (p in rootProject.children) {
17+
if (p.children.isEmpty()) {
18+
// Rename leaf projects only
19+
// E.g. we don't expect to publish examples as a Maven module
20+
p.name = rootProject.name.toLowerCase() + "-" + p.name
21+
}
22+
}

0 commit comments

Comments
 (0)
Please sign in to comment.