-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gradle: stand-alone build, independent from css4j-dist.
- Loading branch information
Showing
9 changed files
with
645 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,8 @@ | |
*.iws | ||
|
||
# Gradle | ||
/.gradle | ||
**/.gradle | ||
/build/ | ||
/buildSrc/build/ | ||
|
||
/CHANGES.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
CSS4J AGENT MODULE RELEASE NOTES | ||
================================ | ||
|
||
Release 3.6.0 - July 30, 2021 | ||
----------------------------- | ||
|
||
Release Highlights | ||
------------------ | ||
|
||
* Build improvements. | ||
|
||
The Gradle build is now independent from css4j-dist. | ||
|
||
|
||
Description | ||
----------- | ||
This software contains Java(tm) classes that extend the CSS4J library with a | ||
few user agent helper classes. Unless otherwise noted, this software is provided | ||
under a BSD-style licence (see the LICENSE.txt file, and also LICENSES.txt for | ||
included files that have a different licensing). | ||
|
||
|
||
Java(tm) Runtime Environment requirements | ||
----------------------------------------- | ||
All the classes in the binary package have been compiled with a Java compiler | ||
set to 1.8 compiler compliance level, except the module-info file. | ||
|
||
Building the library requires JDK 15 or higher, although the resulting jar | ||
files can be run with a 1.8 JRE. | ||
|
||
|
||
Software dependencies | ||
===================== | ||
|
||
- The css4j artifact (and its transitive dependencies); version 3.6.0 or higher | ||
is recommended (compatibility with 4.0 or higher is not guaranteed): | ||
https://github.com/css4j/css4j/releases | ||
|
||
- The xml-dtd artifact; version 3.5.1 or higher is recommended: | ||
https://github.com/css4j/xml-dtd/releases | ||
|
||
- The validator.nu html5 parser: https://about.validator.nu/htmlparser/ | ||
|
||
- The SLF4J package, which is a logging package. See http://www.slf4j.org/ | ||
for more information. | ||
|
||
|
||
Optional packages: | ||
|
||
To run the unit tests you need a recent version of JUnit 4. Tests also require | ||
other packages, please see the Gradle build file for details. | ||
|
||
|
||
Project Sites | ||
============= | ||
Project home: https://css4j.github.io/ | ||
Development site: https://github.com/css4j/css4j-agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,224 @@ | ||
plugins { | ||
id 'css4j.java-conventions' | ||
id 'de.jjohannes.extra-java-module-info' | ||
id 'java-library' | ||
id 'maven-publish' | ||
id 'de.jjohannes.extra-java-module-info' version '0.9' | ||
} | ||
|
||
group = 'io.sf.carte' | ||
version = '3.6.0' | ||
|
||
description = 'css4j-agent' | ||
|
||
dependencies { | ||
api project(':css4j') | ||
api "io.sf.carte:xml-dtd:${xmldtdVersion}" | ||
api "nu.validator:htmlparser:${htmlparserVersion}" | ||
api('io.sf.carte:css4j') { | ||
version { | ||
strictly '[3.4.0,4.0[' | ||
prefer '3.6.0' | ||
} | ||
} | ||
api('io.sf.carte:xml-dtd') { | ||
version { | ||
require '[3.4.0,)' | ||
prefer '3.5.1' | ||
} | ||
} | ||
api 'nu.validator:htmlparser:1.4.16' | ||
/* | ||
* The next dependency is not required for compiling, but this one was | ||
* optional in the core module and it is mandatory for user agents. So it is | ||
* set as a mandatory dependency here. | ||
* The next dependency is not required for compiling, but it was optional | ||
* in the core module and is mandatory for user agents. So it is set as a | ||
* mandatory dependency here. | ||
*/ | ||
api "org.slf4j:slf4j-api:${slf4jVersion}" | ||
testImplementation project(path: ':css4j', configuration: 'tests') | ||
api('org.slf4j:slf4j-api') { | ||
version { | ||
require '[1.7.28,)' | ||
prefer '1.7.32' | ||
} | ||
} | ||
testImplementation(group: 'io.sf.carte', name: 'css4j', classifier: 'tests') { | ||
version { | ||
strictly '[3.4.0,4.0[' | ||
prefer '3.6.0' | ||
} | ||
} | ||
testImplementation 'junit:junit:4.13.1' | ||
} | ||
|
||
extraJavaModuleInfo { | ||
failOnMissingModuleInfo.set(false) | ||
automaticModule("htmlparser-${htmlparserVersion}.jar", 'htmlparser') | ||
automaticModule('htmlparser-1.4.16.jar', 'htmlparser') | ||
} | ||
|
||
description = 'css4j-agent' | ||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
compileJava.dependsOn tasks.jvmVersionAttribute | ||
repositories { | ||
maven { | ||
url = uri('https://repo.maven.apache.org/maven2/') | ||
} | ||
maven { | ||
url "https://css4j.github.io/maven/" | ||
mavenContent { | ||
releasesOnly() | ||
} | ||
content { | ||
includeGroup 'io.sf.carte' | ||
includeGroup 'io.sf.jclf' | ||
} | ||
} | ||
} | ||
|
||
publishing.publications.maven(MavenPublication).pom { | ||
description = "CSS4J agent module" | ||
sourceSets { | ||
main { | ||
java { | ||
srcDirs = ['src'] | ||
includes += ["**/*.java"] | ||
} | ||
resources { | ||
srcDirs = ['src'] | ||
excludes += ["**/*.java"] | ||
} | ||
} | ||
test { | ||
java { | ||
srcDirs = ['junit'] | ||
includes += ["**/*.java"] | ||
} | ||
resources { | ||
srcDirs = ['junit'] | ||
excludes += ["**/*.java"] | ||
} | ||
} | ||
} | ||
|
||
java { | ||
withJavadocJar() | ||
tasks.compileJava { | ||
excludes += ['module-info.java'] | ||
modularity.inferModulePath = false | ||
} | ||
|
||
tasks.register('compileModuleInfo', JavaCompile) { | ||
description = 'Compile module-info to Java 11 bytecode' | ||
dependsOn tasks.compileJava | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
source = sourceSets.main.java | ||
classpath = sourceSets.main.compileClasspath | ||
destinationDirectory = sourceSets.main.java.destinationDirectory | ||
modularity.inferModulePath = true | ||
includes = ['module-info.java'] | ||
} | ||
|
||
classes.dependsOn compileModuleInfo | ||
|
||
// Check bytecode version, in case some other task screws it | ||
tasks.register('checkLegacyJava') { | ||
description = 'Check that classes are Java 8 bytecode (except module-info)' | ||
def classdir = sourceSets.main.output.classesDirs.files.stream().findAny().get() | ||
def classfiles = fileTree(classdir).matching({it.exclude('module-info.class')}).files | ||
doFirst() { | ||
if (!classfiles.isEmpty()) { | ||
def classfile = classfiles.stream().findAny().get() | ||
if (classfile != null) { | ||
def classbytes = classfile.bytes | ||
def bcversion = classbytes[6] * 128 + classbytes[7] | ||
if (bcversion != 52) { | ||
throw new GradleException("Bytecode on " + classfile + | ||
" is not valid Java 8. Version should be 52, instead is " + bcversion) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
classes.finalizedBy checkLegacyJava | ||
|
||
tasks.register('lineEndingConversion', CRLFConvert) { | ||
file "$rootDir/LICENSE.txt" | ||
file "$rootDir/LICENSES.txt" | ||
file "$rootDir/CHANGES.txt" | ||
file "$rootDir/RELEASE_NOTES.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') | ||
options.links 'https://docs.oracle.com/en/java/javase/11/docs/api/' | ||
} | ||
|
||
// Reproducible build | ||
tasks.withType(AbstractArchiveTask).configureEach { | ||
preserveFileTimestamps = false | ||
reproducibleFileOrder = true | ||
} | ||
|
||
tasks.withType(PublishToMavenRepository) { task -> | ||
doFirst { | ||
if (repository == publishing.repositories.getByName('mavenRepo')) { | ||
logger.lifecycle "Deploying artifacts to \"${it.repository.url}\"" | ||
} | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
description = 'css4j agent module' | ||
from(components.java) | ||
pom { | ||
description = 'css4j agent module' | ||
url = "https://github.com/css4j/css4j-agent/" | ||
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 = "${buildDir}/repository/releases" | ||
} | ||
if (project.hasProperty('mavenSnapshotRepoUrl') && project.mavenSnapshotRepoUrl) { | ||
snapshotsUrl = mavenSnapshotRepoUrl | ||
} else { | ||
snapshotsUrl = "${buildDir}/repository/snapshots" | ||
} | ||
url = version.endsWith('-SNAPSHOT') ? snapshotsUrl : releasesUrl | ||
if (project.hasProperty('mavenRepoUsername') && | ||
project.hasProperty('mavenRepoPassword')) { | ||
credentials.username = mavenRepoUsername | ||
credentials.password = mavenRepoPassword | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
/** | ||
* Converts line endings to CRLF (Windows) | ||
* <p> | ||
* Usage: | ||
* </p> | ||
* <code> | ||
* tasks.register('lineEndingConversion', CRLFConvert) { | ||
* file "path/to/file1.txt" | ||
* file "path/to/fileN.txt" | ||
* } | ||
* </code> | ||
*/ | ||
class CRLFConvert extends DefaultTask { | ||
|
||
private static final String CRLF = "\r\n" | ||
private static final String LF = "\n" | ||
|
||
private files = [] | ||
|
||
@TaskAction | ||
def action() { | ||
files.each { path -> | ||
File file = new File(path) | ||
String content = file.text | ||
content = content.replaceAll(/\r\n/, LF) | ||
file.write(content.replaceAll(/\n|\r/, CRLF)) | ||
} | ||
} | ||
|
||
def file(String path) { | ||
this.files << path | ||
} | ||
} |
Oops, something went wrong.