diff --git a/README.md b/README.md index 048815c..f12b718 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/build.gradle b/build.gradle index b09952b..6fd15d8 100644 --- a/build.gradle +++ b/build.gradle @@ -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 + } + } + } +} diff --git a/buildSrc/src/main/groovy/carte.java-conventions.gradle b/buildSrc/src/main/groovy/carte.java-conventions.gradle deleted file mode 100644 index 2b2ca7d..0000000 --- a/buildSrc/src/main/groovy/carte.java-conventions.gradle +++ /dev/null @@ -1,114 +0,0 @@ -plugins { - id 'java-library' - id 'maven-publish' -} - -repositories { - maven { - url = uri('https://repo.maven.apache.org/maven2/') - } -} - -subprojects { - modularity.mixedJavaRelease 7 -} - -sourceSets { - main { - java { - srcDirs = ['src'] - includes += ["**/*.java"] - } - resources { - srcDirs = ['src'] - excludes += ["**/*.java"] - } - } - test { - java { - srcDirs = ['junit'] - includes += ["**/*.java"] - } - resources { - srcDirs = ['junit'] - excludes += ["**/*.java"] - } - } -} - -group = 'io.sf.carte' - -java { - sourceCompatibility = JavaVersion.VERSION_11 - withJavadocJar() - withSourcesJar() -} - -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 { - 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 - } - } - } -} \ No newline at end of file