Giter Site home page Giter Site logo

lint-maven-plugin's People

Contributors

ddossot avatar gaul avatar gdenning avatar lewisd32 avatar lkwg82 avatar stephan202 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lint-maven-plugin's Issues

add an possibility to collect all violations of a reactor project

I'd like to see an option, a lint check can collect all violations and dont stop at the first analysis of a module it detects some violations

[INFO] Reactor Summary:
[INFO] 
[INFO] sonar-mojo-bridge-parent .......................... SUCCESS [2.380s]
[INFO] sonar-mojo-bridge-configuration ................... SUCCESS [0.301s]
[INFO] sonar-mojo-bridge-maven-internals ................. SUCCESS [1.867s]
[INFO] sonar-mojo-bridge-utils ........................... SUCCESS [0.348s]
[INFO] sonar-mojo-bridge-testing ......................... SUCCESS [0.309s]
[INFO] sonar-mojo-bridge-maven-enforcer .................. SUCCESS [0.525s]
[INFO] sonar-mojo-bridge-maven-versions .................. SUCCESS [0.395s]
[INFO] Sonar mojo bridge plugin .......................... FAILURE [0.254s]
[INFO] sonar-mojo-bridge-maven-versions-integration ...... SKIPPED

Test project can be https://github.com/SonarCommunity/sonar-mojo-bridge/tree/maven-lint-integration

RedundantDependencyVersionsRule false positive

Running mvn lint:check on the POM below yields the following:

[INFO] --- lint-maven-plugin:0.0.8:check (default-cli) @ example ---
 WARN [RedundantDependencyVersionsRule:81] 2013-10-28 13:48:35,050 - java.lang.IllegalStateException: Found 2 objects using path dependencies[groupId='com.lewisd' and artifactId='lint-maven-plugin' and type='jar']
 WARN [RedundantDependencyVersionsRule:81] 2013-10-28 13:48:35,054 - java.lang.IllegalStateException: Found 2 objects using path dependencyManagement/dependencies[groupId='com.lewisd' and artifactId='lint-maven-plugin' and type='jar']

Note that the POM is crafted to be a minimal example. The issue also occurs when the dependencyManagement section is in a parent POM (as it normally would be).

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>example</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.lewisd</groupId>
                <artifactId>lint-maven-plugin</artifactId>
                <version>0.0.8</version>
            </dependency>
            <dependency>
                <groupId>com.lewisd</groupId>
                <artifactId>lint-maven-plugin</artifactId>
                <version>0.0.8</version>
                <classifier>javadoc</classifier>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.lewisd</groupId>
            <artifactId>lint-maven-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>com.lewisd</groupId>
            <artifactId>lint-maven-plugin</artifactId>
            <classifier>javadoc</classifier>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.lewisd</groupId>
                <artifactId>lint-maven-plugin</artifactId>
                <version>0.0.8</version>
                <executions>
                    <execution>
                        <id>validate-pom</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <rules>
                        <excludes>
                            <exclude>OSS*</exclude>
                        </excludes>
                    </rules>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Status of this project

I like the idea behind this plugin a lot, but it seems there's been no activity for over a year. @lewisd32, can you please share your thoughts on the roadmap/future of this project?

IllegalStateException: RedundantDependencyVersionsRule with maven expressions

I guess here is something wrong with evaluation maven expressions

[INFO] ------------------------------------------------------------------------
[INFO] Building sonar-mojo-bridge-maven-internals 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- lint-maven-plugin:0.0.7:check (default-cli) @ sonar-mojo-bridge-maven-internals ---
 WARN [RedundantDependencyVersionsRule:80] 2013-08-23 23:32:24,161 - java.lang.IllegalStateException: Could not resolve Dependency {groupId=org.codehaus.sonar, artifactId=sonar-plugin-api, version=${sonar-plugin-api.version}, type=jar} using path null[groupId='org.codehaus.sonar' and artifactId='sonar-plugin-api' and type='jar']
 WARN [RedundantDependencyVersionsRule:80] 2013-08-23 23:32:24,168 - java.lang.IllegalStateException: Could not resolve Dependency {groupId=org.codehaus.mojo, artifactId=versions-maven-plugin, version=${versions-maven-plugin.version}, type=jar} using path null[groupId='org.codehaus.mojo' and artifactId='versions-maven-plugin' and type='jar']
[INFO] Writing summary report

from project: https://github.com/SonarCommunity/sonar-mojo-bridge/tree/maven-lint-integration

Thx anyway, for your great plugin!

NPE while building

I get the following NullPointerException in my build. Please let me know if you need more debugging information.

The error happens when I invoke mvn verify package but not mvn verify or mvn package.

[ERROR] Failed to execute goal com.lewisd:lint-maven-plugin:0.0.8:check (lint-maven) on project payments-api: Error while performing check: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.lewisd:lint-maven-plugin:0.0.8:check (lint-maven) on project payments-api: Error while performing check
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error while performing check
        at com.lewisd.maven.lint.plugin.CheckMojo.executeRule(CheckMojo.java:160)
        at com.lewisd.maven.lint.plugin.CheckMojo.executeRules(CheckMojo.java:151)
        at com.lewisd.maven.lint.plugin.CheckMojo.execute(CheckMojo.java:107)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more
Caused by: java.lang.NullPointerException
        at com.lewisd.maven.lint.rules.basic.GroupArtifactVersionMustBeInCorrectOrderRule$InputLocationMapValueComparator.compare(GroupArtifactVersionMustBeInCorrectOrderRule.java:135)
        at com.lewisd.maven.lint.rules.basic.GroupArtifactVersionMustBeInCorrectOrderRule$InputLocationMapValueComparator.compare(GroupArtifactVersionMustBeInCorrectOrderRule.java:131)
        at java.util.TreeMap.put(TreeMap.java:545)
        at com.lewisd.maven.lint.rules.basic.GroupArtifactVersionMustBeInCorrectOrderRule.invoke(GroupArtifactVersionMustBeInCorrectOrderRule.java:83)
        at com.lewisd.maven.lint.RuleInvoker.invokeRule(RuleInvoker.java:21)
        at com.lewisd.maven.lint.plugin.CheckMojo.executeRule(CheckMojo.java:158)
        ... 23 more
[ERROR] 

Make it easier to configure which rules are desired

For users of the plugin, configuring which rules are run should be easier to configure. Ideally, this would be done just through their pom, without having to mess with other xml files.
It should be easy for users to say "all rules, except these ones", or "only these rules"

create violation for <execution></execution> block without id

We faced an error, while we override an plugin configuration from the parent pom because we missed to insert an xyz

in parent pom.xml

<execution>
  <id>a</id>
</execution>

in project pom.xml

<execution>
  <id>b</id>
</execution>

will be merged in effective pom

<execution>
  <id>a</id>
</execution>
<execution>
  <id>b</id>
</execution>

but without setting an explicit id

<execution>
   ...
</execution>

this could be detected by a formalism aka violation

Any feedback welcome!

NPE in GAVOrder rule

I get a NullPointerException in my build when I use the GAVOrder rule. Potentially looks like a similar bug to this issue, which seems like it was fixed in an earlier version of Maven than the one I am using.

Error Stacktrace

xxxx-MacBook-Pro:my-app xxxx$ mvn clean verify -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.mycompany.app:my-app >----------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ my-app ---
[INFO] 
[INFO] --- lint-maven-plugin:0.0.11:check (pom-lint) @ my-app ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.132 s
[INFO] Finished at: 2019-09-24T17:06:00-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.lewisd:lint-maven-plugin:0.0.11:check (pom-lint) on project my-app: Error while performing check: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.lewisd:lint-maven-plugin:0.0.11:check (pom-lint) on project my-app: Error while performing check
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error while performing check
    at com.lewisd.maven.lint.plugin.CheckMojo.executeRule (CheckMojo.java:188)
    at com.lewisd.maven.lint.plugin.CheckMojo.executeRules (CheckMojo.java:179)
    at com.lewisd.maven.lint.plugin.CheckMojo.execute (CheckMojo.java:131)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.NullPointerException
    at com.lewisd.maven.lint.util.ModelUtil.getLocations (ModelUtil.java:165)
    at com.lewisd.maven.lint.util.ModelUtil.getLocations (ModelUtil.java:111)
    at com.lewisd.maven.lint.rules.basic.GroupArtifactVersionMustBeInCorrectOrderRule.invoke (GroupArtifactVersionMustBeInCorrectOrderRule.java:69)
    at com.lewisd.maven.lint.RuleInvoker.invokeRule (RuleInvoker.java:21)
    at com.lewisd.maven.lint.plugin.CheckMojo.executeRule (CheckMojo.java:186)
    at com.lewisd.maven.lint.plugin.CheckMojo.executeRules (CheckMojo.java:179)
    at com.lewisd.maven.lint.plugin.CheckMojo.execute (CheckMojo.java:131)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Environment

It seems like it may be an environment issue, as my coworkers aren't able to replicate this bug on their local machines.

I'm running MacOS Mojave 10.14.5. Maven was installed via Homebrew and Java installed with a dmg package. Maven and Java versions:

xxxx-MacBook-Pro:~ xxxx$ mvn --version
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T08:06:16-07:00)
Maven home: /usr/local/Cellar/maven/3.6.2/libexec
Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.5", arch: "x86_64", family: "mac"

How to Reproduce Error

Here are the steps to reproduce the error:

Make a directory, cd into it, and init Maven

mkdir linker-test
cd linker-test
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false

Replace the contents of the pom.xml file with the code below. This is essentially the default pom.xml file, but removing the forward declaring of plugins and adding in the lint-maven-plugin with the GAVOrder Rule.

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>my-app</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>


  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
      <plugins>
        <!-- Lint Maven pom.xml files -->
        <plugin>
          <groupId>com.lewisd</groupId>
          <artifactId>lint-maven-plugin</artifactId>
          <version>0.0.11</version>
          <configuration>
            <failOnViolation>true</failOnViolation>
            <onlyRunRules>
              <rule>DotVersionProperty</rule>
              <rule>VersionProp</rule>
              <rule>GAVOrder</rule>
              <rule>RedundantDepVersion</rule>
              <rule>RedundantPluginVersion</rule>
              <rule>DuplicateDep</rule>
              <rule>ExecutionId</rule>
            </onlyRunRules>
          </configuration>
          <executions>
            <execution>
              <id>pom-lint</id>
              <phase>validate</phase>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<!--        <plugin>-->
<!--          <artifactId>maven-site-plugin</artifactId>-->
<!--          <version>3.7.1</version>-->
<!--        </plugin>-->
<!--        <plugin>-->
<!--          <artifactId>maven-project-info-reports-plugin</artifactId>-->
<!--          <version>3.0.0</version>-->
<!--        </plugin>-->
      </plugins>
  </build>
</project>

Then, from within the Maven app (my-app by default), run mvn clean verify to replicate the error.

cd my-app
mvn clean verify

Note that commenting out <rule>GAVOrder</rule> (line 41 in pom.xml) yields a successful build.

Feature request: Option to warn on multiprojects

Some Java developers consider nested Maven multiprojects to be an anti-pattern that introduces more problems than it solves. While I don't 100% agree, I do think it would be helpful to offer a linter rule that checks for this, disabled by default. What do you think?

Feature request: Block springframework starter artifactIds

In our company, we like to control everything going to production.
Therefore, dependency management is very important.
Some lazy developers tend to use the Spring starter packages, like org.springframework.boot:spring-boot-starter-actuator
These starter packages usually tend to pull in other unwanted packages.
It would be nice to have a rule which can block Springframework starter packages in general.

When not parameterized, it could scan for "groupId".startsWith "org.springframework" and "artifactId".contains "-starter-"

Variable vs. literal confusion

Consider the following POM. It defines two identical dependencies in its <dependencyManagement> section, but in one case the groupdId is specified as a variable, while in the other case it's specified verbatim:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.lewisd</groupId>
    <artifactId>example</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>lint-maven-plugin</artifactId>
                <version>0.0.8</version>
            </dependency>
            <dependency>
                <groupId>com.lewisd</groupId>
                <artifactId>lint-maven-plugin</artifactId>
                <version>0.0.8</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.lewisd</groupId>
            <artifactId>lint-maven-plugin</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.lewisd</groupId>
                <artifactId>lint-maven-plugin</artifactId>
                <version>0.0.8</version>
                <executions>
                    <execution>
                        <id>validate-pom</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <rules>
                        <excludes>
                            <exclude>OSS*</exclude>
                        </excludes>
                    </rules>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Running mvn com.lewisd:lint-maven-plugin:0.0.9-SNAPSHOT:check on this POM causes the following stacktrace to be logged:

[WARNING] 
java.lang.IllegalStateException: Found 2 objects using path dependencyManagement/dependencies[groupId='com.lewisd' and artifactId='lint-maven-plugin' and type='jar' and not(classifier)]
    at com.lewisd.maven.lint.rules.AbstractReduntantVersionRule.resolveObject(AbstractReduntantVersionRule.java:137)
    at com.lewisd.maven.lint.rules.AbstractReduntantVersionRule.tryResolveObject(AbstractReduntantVersionRule.java:87)
    at com.lewisd.maven.lint.rules.AbstractReduntantVersionRule.checkForRedundantVersions(AbstractReduntantVersionRule.java:50)
    at com.lewisd.maven.lint.rules.basic.RedundantDependencyVersionsRule.invoke(RedundantDependencyVersionsRule.java:56)
    at com.lewisd.maven.lint.RuleInvoker.invokeRule(RuleInvoker.java:21)
    at com.lewisd.maven.lint.plugin.CheckMojo.executeRule(CheckMojo.java:181)
    at com.lewisd.maven.lint.plugin.CheckMojo.executeRules(CheckMojo.java:174)
    at com.lewisd.maven.lint.plugin.CheckMojo.execute(CheckMojo.java:138)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

This happens both before and after the merge of #19. (And also when one uses 0.0.8, though in that case the stack trace is suppressed.) The DuplicateDep rule is not triggered and the build will not fail (!).

Note that the implicated IllegalStateException is precisely the one discussed in #19. It's good that we didn't decide to change it to an AssertionError, cause clearly this is a valid (albeit undesirable) state.

What's extra interesting about this is that this POM throws off even Maven: normally Maven itself will warn about the duplicate dependency declaration in the <dependencyManagement> section, but for this POM it doesn't. Replacing ${project.groupId} with com.lewisd will make both Maven and the plugin complain.

The 'list' goal has been broken since 0.0.9

[ERROR] Failed to execute goal com.lewisd:lint-maven-plugin:0.0.9:list (default-cli) on project lint-maven-plugin: Execution default-cli of goal com.lewisd:lint-maven-plugin:0.0.9:list failed: Error creating bean with name 'RedundantDependencyVersionsRule' defined in class path resource [config/maven_lint_rules.xml]: Unsatisfied dependency expressed through constructor argument with index 2 of type [org.apache.maven.plugin.PluginParameterExpressionEvaluator]: : No matching bean of type [org.apache.maven.plugin.PluginParameterExpressionEvaluator] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.apache.maven.plugin.PluginParameterExpressionEvaluator] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

I feel like having non-test scoped <dependencies/> in a pom packaging project is something that could be checked by maven lint

So, we had a situation where we depending on a war project for some html files. We did this as a straight war dependency and let maven and the war plugin do the necessary overlay magic.

However, their war was accidentally including (unused) Spring jars in the WEB-INF/lib directory.

It was doing so because the parent project of their war had a <dependencies> stanza (instead of <dependencyManagement>) listing Spring and a few other things.

Worse, they had a jar project with the same parent that was relying on the dependency stanza being there.

I feel like there's almost never a reason to have dependencies listed in a pom project, instead they should be dependencyManagement.

I could be wrong though.

Recommend <type>test-jar</type> over <classifier>tests</classifier>

I have a parent pom that lists two sub-projects (A and B, of course). B's compile classpath needs classes found in A's src/test/java. It's possible to get these into B's classpath by either method listed above in B's pom.xml.

However, my IDE (with both A and B imported) is not smart enough to realize that the classifier-way means to use the test classpath of project A, and upon a full rebuild I get compiler errors.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.