11plugins {
2+ id ' com.diffplug.spotless' version ' 6.23.1'
3+ id ' com.github.node-gradle.node' version ' 7.0.1'
24 id ' java-library'
35 id ' maven-publish'
46 id ' signing'
@@ -7,7 +9,7 @@ plugins {
79group = ' org.sqids'
810version = ' 0.1.0-SNAPSHOT'
911
10- String rootArtifactiId = ' sqids'
12+ String rootArtifactId = ' sqids'
1113String projectUrl = ' https://sqids.org/java'
1214
1315repositories {
@@ -17,7 +19,7 @@ repositories {
1719dependencies {
1820 testImplementation platform(' org.junit:junit-bom:5.10.0' )
1921 testImplementation ' org.junit.jupiter:junit-jupiter'
20- testRuntimeOnly( " org.junit.platform:junit-platform-launcher" )
22+ testRuntimeOnly ' org.junit.platform:junit-platform-launcher'
2123}
2224
2325test {
@@ -34,20 +36,19 @@ java {
3436
3537publishing {
3638 publications {
37-
3839 mavenJava(MavenPublication ) {
3940 groupId = group
40- artifactId = rootArtifactiId
41+ artifactId = rootArtifactId
4142 version = version
4243 from components. java
4344 pom {
4445 name = ' Sqids'
4546 description = ' Generate short YouTube-looking IDs from numbers.'
4647 url = projectUrl
4748 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 '
5152 ]
5253 licenses {
5354 license {
@@ -72,12 +73,12 @@ publishing {
7273 }
7374 repositories {
7475 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/'
7778 url = version. endsWith(' SNAPSHOT' ) ? snapshotsRepoUrl : releasesRepoUrl
7879 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' )
8182 }
8283 }
8384 }
@@ -86,3 +87,35 @@ publishing {
8687 sign publishing. publications. mavenJava
8788 }
8889}
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 ' bin' , ' 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