Skip to content

css4j/css4j

Repository files navigation

CI workflow

css4j

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).


Features

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:


Java™ 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.java file.

Building the library requires JDK 11 or higher.


Build from source

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 the build/reports/jacoco/test/html directory)
  • ./gradlew publish (deploys to a Maven repository, as described in the publishing.repositories.maven block of build.gradle)

Usage from a Gradle project

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 {
            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.


Usage from a Maven build

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>

In your IDE

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.


Fuzzing

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.


Software dependencies

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:

Compile-time dependencies

Test dependencies


Website

For more information please see https://css4j.github.io/

About

CSS parser with Event and Object Model APIs, a DOM wrapper and a CSS-aware DOM implementation. Written in the Java™ language.

Topics

Resources

License

Stars

Watchers

Forks

Languages