Skip to content

Commit

Permalink
Gradle: use org.javamodularity.moduleplugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosame committed Jun 1, 2021
1 parent 5eeaea8 commit 0eabeac
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 119 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Use:

Before deploying to a remote Maven repository, please read the
`publishing.repositories.maven` block of
[carte.java-conventions.gradle](https://github.com/css4j/carte-util/blob/master/buildSrc/src/main/groovy/carte.java-conventions.gradle)
[build.gradle](https://github.com/css4j/carte-util/blob/master/build.gradle)
to learn which properties you need to set (like `mavenReleaseRepoUrl`or
`mavenRepoUsername`), either at the [command line](https://docs.gradle.org/current/userguide/build_environment.html#sec:project_properties)
(`-P` option) or your `GRADLE_USER_HOME/gradle.properties` file.
119 changes: 115 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,126 @@
plugins {
id 'carte.java-conventions'
id 'java-library'
id 'maven-publish'
id 'org.javamodularity.moduleplugin' version '1.8.6' apply false
}

group = 'io.sf.carte'

description = 'carte-util'

publishing.publications.maven(MavenPublication).pom {
description = 'Carte utility library'
version = '3.5.1'

sourceSets {
main {
java {
srcDirs = ['src']
includes += ["**/*.java"]
}
resources {
srcDirs = ['src']
excludes += ["**/*.java"]
}
}
test {
java {
srcDirs = ['junit']
includes += ["**/*.java"]
}
resources {
srcDirs = ['junit']
excludes += ["**/*.java"]
}
}
}

version = '3.5.1'
java {
withJavadocJar()
withSourcesJar()
modularity.inferModulePath = false
}

apply plugin: 'org.javamodularity.moduleplugin'

modularity.mixedJavaRelease 8, 11

test.moduleOptions.runOnClasspath = true

dependencies {
testImplementation 'junit:junit:4.13.1'
}

repositories {
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
}

tasks.register('lineEndingConversion', CRLFConvert) {
description 'Convert LICENSE.txt to Windows line endings'
file "$rootDir/LICENSE.txt"
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

tasks.withType(Javadoc) {
failOnError false
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charset', 'UTF-8')
}

publishing {
publications {
maven(MavenPublication) {
from(components.java)
pom {
description = 'Carte utility library'
url = "https://github.com/css4j/carte-util"
licenses {
license {
name = "BSD 3-clause license"
url = "https://css4j.github.io/LICENSE.txt"
}
}
}
}
}
repositories {
maven {
name = 'mavenRepo'
/*
* The following section applies to the 'publish' task:
*
* If you plan to deploy to a repository, please configure the
* 'mavenReleaseRepoUrl' and/or 'mavenSnapshotRepoUrl' properties
* (for example in GRADLE_USER_HOME/gradle.properties).
*
* Otherwise, Gradle shall create a 'build/repository' subdirectory
* at ${rootDir} and deploy there.
*
* Properties 'mavenRepoUsername' and 'mavenRepoPassword' can also
* be set (generally from command line).
*/
def releasesUrl
def snapshotsUrl
if (project.hasProperty('mavenReleaseRepoUrl') && project.mavenReleaseRepoUrl) {
releasesUrl = mavenReleaseRepoUrl
} else {
releasesUrl = "${rootDir}/build/repository/releases"
}
if (project.hasProperty('mavenSnapshotRepoUrl') && project.mavenSnapshotRepoUrl) {
snapshotsUrl = mavenSnapshotRepoUrl
} else {
snapshotsUrl = "${rootDir}/build/repository/snapshots"
}
url = version.endsWith('-SNAPSHOT') ? snapshotsUrl : releasesUrl
if (project.hasProperty('mavenRepoUsername') &&
project.hasProperty('mavenRepoPassword')) {
credentials.username = mavenRepoUsername
credentials.password = mavenRepoPassword
}
}
}
}
114 changes: 0 additions & 114 deletions buildSrc/src/main/groovy/carte.java-conventions.gradle

This file was deleted.

0 comments on commit 0eabeac

Please sign in to comment.