1
1
plugins {
2
+ id ' com.diffplug.spotless' version ' 6.23.1'
3
+ id ' com.github.node-gradle.node' version ' 7.0.1'
2
4
id ' java-library'
3
5
id ' maven-publish'
4
6
id ' signing'
@@ -7,7 +9,7 @@ plugins {
7
9
group = ' org.sqids'
8
10
version = ' 0.1.0-SNAPSHOT'
9
11
10
- String rootArtifactiId = ' sqids'
12
+ String rootArtifactId = ' sqids'
11
13
String projectUrl = ' https://sqids.org/java'
12
14
13
15
repositories {
@@ -17,7 +19,7 @@ repositories {
17
19
dependencies {
18
20
testImplementation platform(' org.junit:junit-bom:5.10.0' )
19
21
testImplementation ' org.junit.jupiter:junit-jupiter'
20
- testRuntimeOnly( " org.junit.platform:junit-platform-launcher" )
22
+ testRuntimeOnly ' org.junit.platform:junit-platform-launcher'
21
23
}
22
24
23
25
test {
@@ -34,20 +36,19 @@ java {
34
36
35
37
publishing {
36
38
publications {
37
-
38
39
mavenJava(MavenPublication ) {
39
40
groupId = group
40
- artifactId = rootArtifactiId
41
+ artifactId = rootArtifactId
41
42
version = version
42
43
from components. java
43
44
pom {
44
45
name = ' Sqids'
45
46
description = ' Generate short YouTube-looking IDs from numbers.'
46
47
url = projectUrl
47
48
properties = [
48
- " parent.groupId" : " org.sonatype.oss" ,
49
- " parent.artifactId" : " oss-parent" ,
50
- " parent.version" : " 7 "
49
+ ' parent.groupId' : ' org.sonatype.oss' ,
50
+ ' parent.artifactId' : ' oss-parent' ,
51
+ ' parent.version' : ' 7 '
51
52
]
52
53
licenses {
53
54
license {
@@ -72,12 +73,12 @@ publishing {
72
73
}
73
74
repositories {
74
75
maven {
75
- def releasesRepoUrl = ' https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
76
- def snapshotsRepoUrl = ' https://s01.oss.sonatype.org/content/repositories/snapshots/'
76
+ String releasesRepoUrl = ' https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
77
+ String snapshotsRepoUrl = ' https://s01.oss.sonatype.org/content/repositories/snapshots/'
77
78
url = version. endsWith(' SNAPSHOT' ) ? snapshotsRepoUrl : releasesRepoUrl
78
79
credentials {
79
- username " ${ System.getenv(" SONATYPE_USERNAME") } "
80
- password " ${ System.getenv(" SONATYPE_PASSWORD") } "
80
+ username System . getenv(' SONATYPE_USERNAME' )
81
+ password System . getenv(' SONATYPE_PASSWORD' )
81
82
}
82
83
}
83
84
}
@@ -86,3 +87,35 @@ publishing {
86
87
sign publishing. publications. mavenJava
87
88
}
88
89
}
90
+
91
+ node {
92
+ download = true
93
+ }
94
+
95
+ String nodeSetup = ' nodeSetup'
96
+ String npmSetup = ' npmSetup'
97
+
98
+ spotless {
99
+ format ' prettier' , {
100
+ target ' **/*.java' , ' **/*.properties' , ' **/*.md' , ' **/*.yml' , ' **/*.yaml'
101
+ targetExclude ' gradle/**/*'
102
+
103
+ boolean isWindows = System . getProperty(' os.name' ). toLowerCase(). contains(' windows' )
104
+ String nodeExec = isWindows ? ' /node.exe' : ' /bin/node'
105
+ String npmExec = isWindows ? ' /npm.cmd' : ' /bin/npm'
106
+
107
+ prettier([' prettier' : ' 3.1.0' , ' prettier-plugin-java' : ' 2.2.0' , ' prettier-plugin-properties' : ' 0.3.0' ])
108
+ .npmInstallCache()
109
+ .npmExecutable(" ${ tasks.named(npmSetup).get().npmDir.get()}${ npmExec} " )
110
+ .nodeExecutable(" ${ tasks.named(nodeSetup).get().nodeDir.get()}${ nodeExec} " )
111
+ .configFile(' .prettierrc.yaml' )
112
+ }
113
+
114
+ groovyGradle {
115
+ greclipse(). configFile(' .greclipse.properties' )
116
+ }
117
+ }
118
+
119
+ tasks. named(' spotlessPrettier' ). configure { task ->
120
+ task. dependsOn(nodeSetup, npmSetup)
121
+ }
0 commit comments