Skip to content

3.0.2

Latest

Choose a tag to compare

@kkorotkov kkorotkov released this 30 Oct 08:08
74606ab

code-analysis 3.0.2

The artifact is published on Maven Central as com.labs64.commons:code-analysis:3.0.2.

What changed

  • The Eclipse formatter profile (labs64-code-formatting/labs64_eclipse_formatter.xml) now sets the Java source, compliance and target platform levels to 17 instead of 1.5, so Spotless formats Java records.

Full Changelog: 3.0.1...3.0.2

Option 1: unpack from the command line (no POM needed)

Unpacks every file in the jar into ./code-analysis:

mvn org.apache.maven.plugins:maven-dependency-plugin:3.11.0:unpack \
  -Dartifact=com.labs64.commons:code-analysis:3.0.2 \
  -DoutputDirectory=code-analysis

Option 2: unpack as part of the build (POM)

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>unpack-code-analysis</id>
            <phase>verify</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>com.labs64.commons</groupId>
                        <artifactId>code-analysis</artifactId>
                        <version>3.0.2</version>
                        <outputDirectory>${project.build.directory}/code-analysis</outputDirectory>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

The files are then available at ${project.build.directory}/code-analysis/labs64-code-formatting/ and ${project.build.directory}/code-analysis/labs64-code-analysis/.

Option 3: add as a dependency of the tool that uses the file (Checkstyle and Spotless examples)

The tools read the files from the plugin's classpath, so no unpacking is needed. Checkstyle with the analysis rules:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>3.6.0</version>
    <configuration>
        <configLocation>labs64-code-analysis/checkstyle.xml</configLocation>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>com.labs64.commons</groupId>
            <artifactId>code-analysis</artifactId>
            <version>3.0.2</version>
        </dependency>
    </dependencies>
</plugin>

SpotBugs and PMD work the same way: <includeFilterFile>labs64-code-analysis/spotbugs.xml</includeFilterFile> for spotbugs-maven-plugin and <ruleset>labs64-code-analysis/pmd.xml</ruleset> for maven-pmd-plugin, each with the same dependency.

Spotless with the formatting files:

<plugin>
    <groupId>com.diffplug.spotless</groupId>
    <artifactId>spotless-maven-plugin</artifactId>
    <version>3.10.4</version>
    <dependencies>
        <dependency>
            <groupId>com.labs64.commons</groupId>
            <artifactId>code-analysis</artifactId>
            <version>3.0.2</version>
        </dependency>
    </dependencies>
    <configuration>
        <java>
            <importOrder>
                <file>labs64-code-formatting/labs64.importorder</file>
            </importOrder>
            <eclipse>
                <version>4.41</version>
                <file>labs64-code-formatting/labs64_eclipse_formatter.xml</file>
            </eclipse>
        </java>
    </configuration>
</plugin>