{"id":13485953,"url":"https://github.com/gaul/modernizer-maven-plugin","last_synced_at":"2025-05-14T12:07:49.872Z","repository":{"id":20879818,"uuid":"24167016","full_name":"gaul/modernizer-maven-plugin","owner":"gaul","description":"Detect uses of legacy Java APIs","archived":false,"fork":false,"pushed_at":"2025-04-01T06:07:21.000Z","size":869,"stargazers_count":381,"open_issues_count":22,"forks_count":56,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-03T22:48:19.944Z","etag":null,"topics":["apache-commons","guava","java","joda-time","maven-plugin","static-analysis"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-09-18T00:06:51.000Z","updated_at":"2025-04-02T02:18:48.000Z","dependencies_parsed_at":"2023-12-01T12:04:54.215Z","dependency_job_id":"7a5fe181-128a-438b-96bb-c113866a9b8a","html_url":"https://github.com/gaul/modernizer-maven-plugin","commit_stats":{"total_commits":373,"total_committers":41,"mean_commits":9.097560975609756,"dds":0.4718498659517426,"last_synced_commit":"a4da4503ed284668aaa5eb368394d3c9f7ffde6b"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fmodernizer-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fmodernizer-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fmodernizer-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fmodernizer-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaul","download_url":"https://codeload.github.com/gaul/modernizer-maven-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248341680,"owners_count":21087709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-commons","guava","java","joda-time","maven-plugin","static-analysis"],"created_at":"2024-07-31T18:00:34.933Z","updated_at":"2025-04-11T04:27:12.330Z","avatar_url":"https://github.com/gaul.png","language":"Java","funding_links":[],"categories":["Projects","Java","项目"],"sub_categories":["Miscellaneous","杂项"],"readme":"Modernizer Maven Plugin\n=======================\n\n[![Maven Central](https://img.shields.io/maven-central/v/org.gaul/modernizer-maven-plugin.svg)](https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22modernizer-maven-plugin%22)\n\nModernizer Maven Plugin detects uses of legacy APIs which modern Java versions\nsupersede.\nThese modern APIs are often more performant, safer, and idiomatic than the\nlegacy equivalents.\nFor example, Modernizer can detect uses of `Vector` instead of `ArrayList`,\n`String.getBytes(String)` instead of `String.getBytes(Charset)`, and\nGuava `Objects.equal` instead of Java 7 `Objects.equals`.\nThe default configuration detects\n[over 200 legacy APIs](https://github.com/gaul/modernizer-maven-plugin/blob/master/modernizer-maven-plugin/src/main/resources/modernizer.xml),\nincluding third-party libraries like\n[Apache Commons](https://commons.apache.org/),\n[Guava](https://github.com/google/guava),\nand [Joda-Time](https://www.joda.org/joda-time/).\n\nConfiguration\n-------------\n\nTo run Modernizer, add the following to the `\u003cplugins\u003e` stanza in your pom.xml\nthen invoke `mvn modernizer:modernizer`:\n\n```xml\n\u003cplugin\u003e\n  \u003cgroupId\u003eorg.gaul\u003c/groupId\u003e\n  \u003cartifactId\u003emodernizer-maven-plugin\u003c/artifactId\u003e\n  \u003cversion\u003e3.1.0\u003c/version\u003e\n  \u003cconfiguration\u003e\n    \u003cjavaVersion\u003e8\u003c/javaVersion\u003e\n  \u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n\nThe `\u003cconfiguration\u003e` stanza can contain several elements:\n\n* `\u003cjavaVersion\u003e` enables violations based on target Java version, e.g., 8.  For example, Modernizer will detect uses of `Vector` as violations when targeting Java 1.2 but not when targeting Java 1.1.  Required parameter.\n* `\u003cfailOnViolations\u003e` fail phase if Modernizer detects any violations.  Defaults to true.\n* `\u003cincludeTestClasses\u003e` run Modernizer on test classes.  Defaults to true.\n* `\u003cviolationsFile\u003e` user-specified violation file.  Also disables standard violation checks. Can point to classpath using absolute paths, e.g. `classpath:/your/file.xml`.\n* `\u003cviolationsFiles\u003e` user-specified violations file.  The latter files override violations from the former ones, including `violationsFile` and the default violations. Can point to classpath using absolute paths, e.g. `classpath:/your/file.xml`.\n* `\u003cexclusionsFile\u003e` disables user-specified violations.  This is a text file with one exclusion per line in the javap format: `java/lang/String.getBytes:(Ljava/lang/String;)[B`.  Empty lines and lines starting with `#` are ignored.\n* `\u003cexclusions\u003e` violations to disable. Each exclusion should be in the javap format: `java/lang/String.getBytes:(Ljava/lang/String;)[B`.\n* `\u003cexclusionPatterns\u003e` violation patterns to disable, specified using `\u003cexclusionPattern\u003e` child elements. Each exclusion should be a regular expression that matches the javap format: `java/lang/.*` of a violation.\n* `\u003cignorePackages\u003e` package prefixes to ignore, specified using `\u003cignorePackage\u003e` child elements. Specifying `foo.bar` subsequently ignores `foo.bar.*`, `foo.bar.baz.*` and so on.\n* `\u003cignoreClassNamePatterns\u003e` full qualified class names (incl. package) to ignore, specified using `\u003cignoreClassNamePattern\u003e` child elements. Each exclusion should be a regular expression that matches a package and/or class; the package will be / not . separated (ASM's format).\n* `\u003cignoreGeneratedClasses\u003e` classes annotated with an annotation whose retention policy is \u003ccode\u003eruntime\u003c/code\u003e or \u003ccode\u003eclass\u003c/code\u003e and whose simple name contain \"Generated\" will be ignored. (Note: both [javax.annotation.Generated](https://docs.oracle.com/javase/8/docs/api/javax/annotation/Generated.html) and [javax.annotation.processing.Generated](https://docs.oracle.com/en/java/javase/11/docs/api/java.compiler/javax/annotation/processing/Generated.html) have [retention policy](https://docs.oracle.com/javase/8/docs/api/index.html?java/lang/annotation/RetentionPolicy.html) SOURCE (aka discarded by compiler).)\n\nTo run Modernizer during the verify phase of your build, add the following to\nthe modernizer `\u003cplugin\u003e` stanza in your pom.xml:\n\n```xml\n\u003cexecutions\u003e\n  \u003cexecution\u003e\n    \u003cid\u003emodernizer\u003c/id\u003e\n    \u003cphase\u003everify\u003c/phase\u003e\n    \u003cgoals\u003e\n      \u003cgoal\u003emodernizer\u003c/goal\u003e\n    \u003c/goals\u003e\n  \u003c/execution\u003e\n\u003c/executions\u003e\n```\n\nCommand-line flags can override Modernizer configuration and\n[ModernizerMojo](https://github.com/gaul/modernizer-maven-plugin/blob/master/modernizer-maven-plugin/src/main/java/org/gaul/modernizer_maven_plugin/ModernizerMojo.java) \ndocuments all of these.  The most commonly used flags:\n\n* `-Dmodernizer.failOnViolations` - fail phase if violations detected, defaults to true\n* `-Dmodernizer.skip` - skip plugin execution, defaults to false\n\n### Output Formats\n\nThe plugin can output Modernizer violations in one of many formats which can be configured with the `\u003cconfiguration\u003e`\nstanza using `\u003coutputFormat\u003e`.\n\nThe currently supported formats and their respective configuration options are outlined below:\n* `CONSOLE` List each violation using Maven's logger. This is the **default** format.\n  * `\u003cviolationLogLevel\u003e` Specify the log level of the logger: `error`, `warn`, `info` or `debug`.\nDefault is `error`.\n* `CODE_CLIMATE` Write the violations according to [Code Climate's Spec](https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md). \nGitLab uses this format for its code quality as shown [here](https://docs.gitlab.com/ee/ci/testing/code_quality.html#implement-a-custom-tool).\n  * `\u003coutputFile\u003e` The full path the file to output to. Default is `${project.build.directory}/code-quality.json`\n  * `\u003ccodeClimateSeverity\u003e` Severity of Modernizer violations for CodeClimate: `INFO`, `MINOR`, `MAJOR`, `CRITICAL` or `BLOCKER`.\nDefault is `MINOR`.\n\nIgnoring elements\n-----------------\n\nCode can suppress violations within a class or method via an annotation.  First\nadd the following dependency to your `pom.xml`:\n\n```xml\n\u003cdependencies\u003e\n  \u003cdependency\u003e\n    \u003cgroupId\u003eorg.gaul\u003c/groupId\u003e\n    \u003cartifactId\u003emodernizer-maven-annotations\u003c/artifactId\u003e\n    \u003cversion\u003e3.1.0\u003c/version\u003e\n  \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\nThen add `@SuppressModernizer` to the element to ignore:\n\n```java\nimport org.gaul.modernizer_maven_annotations.SuppressModernizer;\n\npublic class Example {\n    @SuppressModernizer\n    public static void method() { ... }\n}\n```\n\nReferences\n----------\n\n* [ASM](https://asm.ow2.org/) provides Java bytecode introspection which enables Modernizer's checks\n* [Checkstyle](https://checkstyle.org/) IllegalInstantiation and Regexp checks can mimic some of Modernizer's functionality\n* [Google Error Prone](https://errorprone.info/) JdkObsolete can mimic some of Modernizer's functionality\n* [Gradle Modernizer Plugin](https://github.com/andygoossens/gradle-modernizer-plugin) provides a Gradle interface to Modernizer\n* `javac -Xlint:deprecated` detects uses of interfaces with @Deprecated annotations\n* [Overstock.com library-detectors](https://github.com/overstock/library-detectors) detects uses of interfaces with @Beta annotations\n* [Policeman's Forbidden API Checker](https://github.com/policeman-tools/forbidden-apis) provides similar functionality to Modernizer\n\nLicense\n-------\nCopyright (C) 2014-2025 Andrew Gaul\n\nLicensed under the Apache License, Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaul%2Fmodernizer-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaul%2Fmodernizer-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaul%2Fmodernizer-maven-plugin/lists"}