|
1 | 1 | plugins {
|
2 |
| - id 'css4j.java-conventions' |
3 |
| - id 'de.jjohannes.extra-java-module-info' |
| 2 | + id 'java-library' |
| 3 | + id 'maven-publish' |
| 4 | + id 'de.jjohannes.extra-java-module-info' version '0.9' |
4 | 5 | }
|
5 | 6 |
|
| 7 | +group = 'io.sf.carte' |
| 8 | +version = '3.6.0' |
| 9 | + |
| 10 | +description = 'css4j-awt' |
| 11 | + |
6 | 12 | dependencies {
|
7 |
| - api project(':css4j') |
8 |
| - testImplementation project(path: ':css4j', configuration: 'tests') |
9 |
| - testImplementation "io.sf.carte:xml-dtd:${xmldtdVersion}" |
10 |
| - testImplementation "nu.validator:htmlparser:${htmlparserVersion}" |
11 |
| - testImplementation "org.slf4j:slf4j-api:${slf4jVersion}" |
| 13 | + api('io.sf.carte:css4j') { |
| 14 | + version { |
| 15 | + strictly '[3.4.0,4.0[' |
| 16 | + prefer '3.6.0' |
| 17 | + } |
| 18 | + } |
| 19 | + testImplementation(group: 'io.sf.carte', name: 'css4j', classifier: 'tests') { |
| 20 | + version { |
| 21 | + strictly '[3.4.0,4.0[' |
| 22 | + prefer '3.6.0' |
| 23 | + } |
| 24 | + } |
| 25 | + testImplementation('io.sf.carte:xml-dtd') { |
| 26 | + version { |
| 27 | + strictly '[3.4.0,)' |
| 28 | + prefer '3.5.1' |
| 29 | + } |
| 30 | + } |
| 31 | + testImplementation 'nu.validator:htmlparser:1.4.16' |
| 32 | + testImplementation('org.slf4j:slf4j-api') { |
| 33 | + version { |
| 34 | + strictly '[1.7.28,)' |
| 35 | + prefer '1.7.32' |
| 36 | + } |
| 37 | + } |
| 38 | + testImplementation 'junit:junit:4.13.1' |
12 | 39 | }
|
13 | 40 |
|
14 | 41 | extraJavaModuleInfo {
|
15 | 42 | failOnMissingModuleInfo.set(false)
|
16 |
| - automaticModule("htmlparser-${htmlparserVersion}.jar", 'htmlparser') |
| 43 | + automaticModule('htmlparser-1.4.16.jar', 'htmlparser') |
17 | 44 | }
|
18 | 45 |
|
19 |
| -description = 'css4j-awt' |
| 46 | +java { |
| 47 | + sourceCompatibility = JavaVersion.VERSION_1_8 |
| 48 | + targetCompatibility = JavaVersion.VERSION_1_8 |
| 49 | + withJavadocJar() |
| 50 | + withSourcesJar() |
| 51 | +} |
20 | 52 |
|
21 |
| -compileJava.dependsOn tasks.jvmVersionAttribute |
| 53 | +repositories { |
| 54 | + maven { |
| 55 | + url = uri('https://repo.maven.apache.org/maven2/') |
| 56 | + } |
| 57 | + maven { |
| 58 | + url "https://css4j.github.io/maven/" |
| 59 | + mavenContent { |
| 60 | + releasesOnly() |
| 61 | + } |
| 62 | + content { |
| 63 | + includeGroup 'io.sf.carte' |
| 64 | + includeGroup 'io.sf.jclf' |
| 65 | + } |
| 66 | + } |
| 67 | +} |
22 | 68 |
|
23 |
| -publishing.publications.maven(MavenPublication).pom { |
24 |
| - description = "CSS4J AWT module" |
| 69 | +sourceSets { |
| 70 | + main { |
| 71 | + java { |
| 72 | + srcDirs = ['src'] |
| 73 | + includes += ["**/*.java"] |
| 74 | + } |
| 75 | + resources { |
| 76 | + srcDirs = ['src'] |
| 77 | + excludes += ["**/*.java"] |
| 78 | + } |
| 79 | + } |
| 80 | + test { |
| 81 | + java { |
| 82 | + srcDirs = ['junit'] |
| 83 | + includes += ["**/*.java"] |
| 84 | + } |
| 85 | + resources { |
| 86 | + srcDirs = ['junit'] |
| 87 | + excludes += ["**/*.java"] |
| 88 | + } |
| 89 | + } |
25 | 90 | }
|
26 | 91 |
|
27 |
| -java { |
28 |
| - withJavadocJar() |
| 92 | +tasks.compileJava { |
| 93 | + excludes += ['module-info.java'] |
| 94 | + modularity.inferModulePath = false |
| 95 | +} |
| 96 | + |
| 97 | +tasks.register('compileModuleInfo', JavaCompile) { |
| 98 | + description = 'Compile module-info to Java 11 bytecode' |
| 99 | + dependsOn tasks.compileJava |
| 100 | + sourceCompatibility = JavaVersion.VERSION_11 |
| 101 | + targetCompatibility = JavaVersion.VERSION_11 |
| 102 | + source = sourceSets.main.java |
| 103 | + classpath = sourceSets.main.compileClasspath |
| 104 | + destinationDirectory = sourceSets.main.java.destinationDirectory |
| 105 | + modularity.inferModulePath = true |
| 106 | + includes = ['module-info.java'] |
| 107 | +} |
| 108 | + |
| 109 | +classes.dependsOn compileModuleInfo |
| 110 | + |
| 111 | +// Check bytecode version, in case some other task screws it |
| 112 | +tasks.register('checkLegacyJava') { |
| 113 | + description = 'Check that classes are Java 8 bytecode (except module-info)' |
| 114 | + def classdir = sourceSets.main.output.classesDirs.files.stream().findAny().get() |
| 115 | + def classfiles = fileTree(classdir).matching({it.exclude('module-info.class')}).files |
| 116 | + doFirst() { |
| 117 | + if (!classfiles.isEmpty()) { |
| 118 | + def classfile = classfiles.stream().findAny().get() |
| 119 | + if (classfile != null) { |
| 120 | + def classbytes = classfile.bytes |
| 121 | + def bcversion = classbytes[6] * 128 + classbytes[7] |
| 122 | + if (bcversion != 52) { |
| 123 | + throw new GradleException("Bytecode on " + classfile + |
| 124 | + " is not valid Java 8. Version should be 52, instead is " + bcversion) |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | + } |
| 129 | +} |
| 130 | + |
| 131 | +classes.finalizedBy checkLegacyJava |
| 132 | + |
| 133 | +tasks.register('lineEndingConversion', CRLFConvert) { |
| 134 | + file "$rootDir/LICENSE.txt" |
| 135 | + file "$rootDir/CHANGES.txt" |
| 136 | + file "$rootDir/RELEASE_NOTES.txt" |
| 137 | +} |
| 138 | + |
| 139 | +tasks.withType(JavaCompile) { |
| 140 | + options.encoding = 'UTF-8' |
| 141 | +} |
| 142 | + |
| 143 | +tasks.withType(Javadoc) { |
| 144 | + failOnError false |
| 145 | + options.addStringOption('Xdoclint:none', '-quiet') |
| 146 | + options.addStringOption('encoding', 'UTF-8') |
| 147 | + options.addStringOption('charset', 'UTF-8') |
| 148 | + options.links 'https://docs.oracle.com/en/java/javase/11/docs/api/' |
| 149 | +} |
| 150 | + |
| 151 | +// Reproducible build |
| 152 | +tasks.withType(AbstractArchiveTask).configureEach { |
| 153 | + preserveFileTimestamps = false |
| 154 | + reproducibleFileOrder = true |
| 155 | +} |
| 156 | + |
| 157 | +tasks.withType(PublishToMavenRepository) { task -> |
| 158 | + doFirst { |
| 159 | + if (repository == publishing.repositories.getByName('mavenRepo')) { |
| 160 | + logger.lifecycle "Deploying artifacts to \"${it.repository.url}\"" |
| 161 | + } |
| 162 | + } |
| 163 | +} |
| 164 | + |
| 165 | +publishing { |
| 166 | + publications { |
| 167 | + maven(MavenPublication) { |
| 168 | + description = 'css4j AWT module' |
| 169 | + from(components.java) |
| 170 | + pom { |
| 171 | + description = 'css4j AWT module' |
| 172 | + url = "https://github.com/css4j/css4j-awt/" |
| 173 | + licenses { |
| 174 | + license { |
| 175 | + name = "BSD 3-clause license" |
| 176 | + url = "https://css4j.github.io/LICENSE.txt" |
| 177 | + } |
| 178 | + } |
| 179 | + } |
| 180 | + } |
| 181 | + } |
| 182 | + repositories { |
| 183 | + maven { |
| 184 | + name = 'mavenRepo' |
| 185 | + /* |
| 186 | + * The following section applies to the 'publish' task: |
| 187 | + * |
| 188 | + * If you plan to deploy to a repository, please configure the |
| 189 | + * 'mavenReleaseRepoUrl' and/or 'mavenSnapshotRepoUrl' properties |
| 190 | + * (for example in GRADLE_USER_HOME/gradle.properties). |
| 191 | + * |
| 192 | + * Otherwise, Gradle shall create a 'build/repository' subdirectory |
| 193 | + * at ${rootDir} and deploy there. |
| 194 | + * |
| 195 | + * Properties 'mavenRepoUsername' and 'mavenRepoPassword' can also |
| 196 | + * be set (generally from command line). |
| 197 | + */ |
| 198 | + def releasesUrl |
| 199 | + def snapshotsUrl |
| 200 | + if (project.hasProperty('mavenReleaseRepoUrl') && project.mavenReleaseRepoUrl) { |
| 201 | + releasesUrl = mavenReleaseRepoUrl |
| 202 | + } else { |
| 203 | + releasesUrl = "${buildDir}/repository/releases" |
| 204 | + } |
| 205 | + if (project.hasProperty('mavenSnapshotRepoUrl') && project.mavenSnapshotRepoUrl) { |
| 206 | + snapshotsUrl = mavenSnapshotRepoUrl |
| 207 | + } else { |
| 208 | + snapshotsUrl = "${buildDir}/repository/snapshots" |
| 209 | + } |
| 210 | + url = version.endsWith('-SNAPSHOT') ? snapshotsUrl : releasesUrl |
| 211 | + if (project.hasProperty('mavenRepoUsername') && |
| 212 | + project.hasProperty('mavenRepoPassword')) { |
| 213 | + credentials.username = mavenRepoUsername |
| 214 | + credentials.password = mavenRepoPassword |
| 215 | + } |
| 216 | + } |
| 217 | + } |
29 | 218 | }
|
0 commit comments