This project provides implementations of APIs similar to W3C/WHATWG's:
Unless otherwise noted, this software is provided under a BSD-style license (see also NOTICE.txt for included files that have a different licensing).
The functionality of this library can be divided in the following areas:
-
A CSSOM API very similar to the standard W3C CSS Object Model API, that allows accessing the CSS information (style sheets, inline styles, etc.) in a DOM Document, as well as getting computed styles for its elements.
-
A CSS-enabled native DOM implementation.
-
A DOM wrapper that can be used with an external DOM implementation.
-
A device profile API to encapsulate target device-specific information.
In separate modules you can find:
-
A DOM4J backend (module css4j-dom4j) which uses documents and elements that extend those of dom4j (for those who are comfortable with the dom4j API).
-
User agent helper classes that ease the usage of the library with correct cookie settings etc. (css4j-agent module).
-
A few AWT helper classes (AWT module).
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.java
file.
Building the library requires JDK 11 or higher.
To build css4j from the code that is currently at the Git repository, JDK 11 or later is needed.
You can run a variety of Gradle tasks with the Gradle wrapper (on Windows shells you can omit the ./
):
./gradlew build
(normal build)./gradlew publishToMavenLocal
(to install in local Maven repository)./gradlew copyJars
(to copy jar files into a top-level jar directory)./gradlew testOn8
(run tests with Java 8)./gradlew jacocoTestReport
(produces a test coverage report in thebuild/reports/jacoco/test/html
directory)./gradlew publish
(deploys to a Maven repository, as described in thepublishing.repositories.maven
block of build.gradle)
If your Gradle project depends on css4j, you can use this project's own Maven repository in a repositories
section of
your build file:
repositories {
maven {
url "https://css4j.github.io/maven/"
mavenContent {
releasesOnly()
}
content {
// Include all the groups used by popular io.sf.* projects
includeGroupByRegex 'io\\.sf\\..*'
// Alternatively:
//includeGroup 'io.sf.carte'
//includeGroup 'io.sf.jclf'
}
}
}
please use this repository only for the artifact groups listed in the includeGroup
statements.
Then, in your build.gradle
file:
dependencies {
api "io.sf.carte:css4j:${css4jVersion}"
}
where css4jVersion
would be defined in a gradle.properties
file.
If you build your project (that depends on css4j) with Maven, please note that neither css4j nor some of its dependencies are in Maven Central.
The easiest path is to add the css4j Maven repository to your project's POM:
<repositories>
<repository>
<id>css4j</id>
<name>CSS4J repository</name>
<url>https://css4j.github.io/maven/</url>
</repository>
</repositories>
And then, add the following to the <dependencies>
section of your pom.xml
:
<!-- This artifact is not in Maven Central -->
<dependency>
<groupId>io.sf.carte</groupId>
<artifactId>css4j</artifactId>
<version>${css4j.version}</version>
</dependency>
When running the test suite from your IDE, you may want to exclude the Fuzz
tag from your JUnit Runner configuration, to avoid bootstrapping the fuzzer each
time you run it.
This library includes a Jazzer-based fuzzing test that can be run with
./gradlew fuzzer
as well as within your IDE (in the latter case you have to set the JAZZER_FUZZ
environment variable).
Beware that many of the crashes that it finds are related to the coverage instrumentation and cannot be reproduced outside of the fuzzer.
In case that you do not use a Gradle or Maven build (which would manage the
dependencies according to the relevant .module
or .pom
files), the required
and optional library packages are the following:
-
The jclf-text (5.0.0 or higher) and jclf-linear3 (1.0.0 or higher) modules. See: https://sourceforge.net/projects/jclf
-
The carte-util library; version 3.6.0 or higher.
-
The tokenproducer library; version 3.0 or higher is required.
-
The xml-dtd library; version 4.2.1 or higher is required. It is optional at runtime.
-
SLF4J, which is a logging package. It is optional at runtime.
-
A recent version of JUnit 5 with the
junit-vintage-engine
artifact.
For more information please see https://css4j.github.io/