Skip to content

This Maven plugin automatically generates package-info.java files with JSpecify annotations (@NullMarked or @NullUnmarked), helping you manage nullness boundaries in your Java projects without manual boilerplate.

License

Notifications You must be signed in to change notification settings

bcaillard/jspecify-packageinfo-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSpecify Package Info Generator Maven Plugin

This Maven plugin automatically generates package-info.java files with JSpecify annotations (@NullMarked and @NullUnmarked), helping you manage nullness boundaries in your Java projects without manual boilerplate.

It scans your source directories, creates missing package-info.java files where needed, and adds either @NullMarked or @NullUnmarked based on your configuration. This allows you to systematically adopt JSpecify nullness tracking across your codebase while maintaining a clean structure.

If you discover JSpecify, remember to take a look at NullAway to eliminate NullPointerException in your Java projects.

Goals

  • Automatically creates package-info.java files in packages that are missing them
  • Adds @NullMarked or @NullUnmarked from JSpecify to support null-safety adoption
  • Reduces repetitive manual work when migrating to JSpecify

Requirements

  • Java 11 or higher
  • Maven 3+

Usage

Add the plugin to your pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>io.github.bcaillard.jspecify-utilities</groupId>
            <artifactId>jspecify-packageinfo-generator-maven-plugin</artifactId>
            <version>(pick version)</version>
            <executions>
                <execution>
                    <goals>
                        <!-- 
                            Whether you want to generate package-java.info files from src/main/java.
                            package-info.java are generated in /target/generated-sources/annotations/packages-info/ folder.
                        -->
                        <goal>generate-package-info</goal>
                        <!-- 
                            Whether you want to generate package-java.info files from src/test/java. 
                            package-info.java are generated in /target/generated-test-sources/test-annotations/packages-info/ folder.
                        -->
                        <goal>generate-package-info-test</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <!-- Whether you want skip execution (optional, default is false) -->
                <skip>false</skip>
                <!-- JSpecify annotation to be added to each package-info.java. Choose between NULL_MARKED and NULL_UNMARKED (optional, default is NULL_MARKED) -->
                <annotation>NULL_UNMARKED</annotation>
            </configuration>
        </plugin>
    </plugins>
</build>

Be careful with Maven Compiler Plugin

Since version 3.12.0, there's a regression that makes it impossible to use generated-sources. See MCOMPILER-538.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

About

This Maven plugin automatically generates package-info.java files with JSpecify annotations (@NullMarked or @NullUnmarked), helping you manage nullness boundaries in your Java projects without manual boilerplate.

Topics

Resources

License

Stars

Watchers

Forks

Languages