maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lennart Jörelid <lennart.jore...@gmail.com>
Subject Why would getDependencies() not return all plugin dependencies?
Date Wed, 06 Jul 2016 10:51:10 GMT
Hello all,

I am a tad puzzled here. I got a strange exception from the
maven-checkstyle-plugin during its site generation yesterday. The immediate
reason in the code was rather simple to track and fix (it is done in PR
https://github.com/apache/maven-plugins/pull/88). I also created a
discussion at https://issues.apache.org/jira/browse/MCHECKSTYLE-287.

However - the root cause of this is not clear to me. It seems that the call
to getArtifactMap().get( groupId:artifactId ) returns null - for some, but
not all, artifacts.
So my question is ... why would the call to *plugin.getDependencies()* not
include some of the dependencies added to the plugin?

Log output (I changed the last part of the log statement since this was
captured, but the effect is still the same):

[DEBUG] Generating
/Users/lj/Development/Projects/Skolverket/Repos/framework/persistence/persistence-spi-jpa/target/site/checkstyle.html
[INFO] Generating "Checkstyle" report           ---
maven-checkstyle-plugin:2.18-SNAPSHOT:checkstyle*[DEBUG] Got null
CheckstylePlugin Dependency Artifact from key [se.foo:foo-codestyle].
Not including null Artifact.
[DEBUG] Got null CheckstylePlugin Dependency Artifact from key
[se.jguru.nazgul.tools.codestyle:nazgul-codestyle]. Not including null
Artifact.
[DEBUG] Got null CheckstylePlugin Dependency Artifact from key
[se.foo:foo-codestyle]. Not including null Artifact.
[DEBUG] Got null CheckstylePlugin Dependency Artifact from key
[se.jguru.nazgul.tools.codestyle:nazgul-codestyle]. Not including null
Artifact. *
[DEBUG] executeCheckstyle start headerLocation : LICENSE.txt
[DEBUG] Adding licenceArtifact
[com.puppycrawl.tools:checkstyle:6.11.2] to resourceManager.
[DEBUG] Adding licenceArtifact [org.slf4j:jcl-over-slf4j:1.5.6] to
resourceManager.
[DEBUG] Adding licenceArtifact [org.slf4j:slf4j-jdk14:1.5.6] to resourceManager.


Plugin configuration with relevant plugins:
        <plugin>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>2.18-SNAPSHOT</version>
          <executions>
            ... left out for now...
          </executions>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>6.19</version>
            </dependency>
            <dependency>
              <groupId>se.foo</groupId>
              <artifactId>foo-codestyle</artifactId>
              <version>1.9.3-SNAPSHOT</version>
            </dependency>
            <dependency>
              <groupId>se.jguru.nazgul.tools.codestyle</groupId>
              <artifactId>nazgul-codestyle</artifactId>
              <version>5.0.1</version>
            </dependency>
            <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>jcl-over-slf4j</artifactId>
              <version>1.7.20</version>
            </dependency>
            <dependency>
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-jdk14</artifactId>
              <version>1.7.20</version>
            </dependency>
          </dependencies>
        </plugin>

Relevant part of the plugin code:

private List<Artifact> getCheckstylePluginDependenciesAsArtifacts(
Map<String, Plugin> plugins, String hint )
{
    List<Artifact> artifacts = new ArrayList<>();

    Plugin checkstylePlugin = plugins.get( plugin.getGroupId() + ":" +
plugin.getArtifactId() );
    if ( checkstylePlugin != null )
    {
        for ( *Dependency dep : checkstylePlugin.getDependencies()* )
*// Why do we not get all the Dependencies here?*
        {
         // @todo if we can filter on hints, it should be done here...
            String depKey = dep.getGroupId() + ":" + dep.getArtifactId();
            final Artifact artifact = (Artifact)
plugin.getArtifactMap().get( depKey );

            if ( artifact != null )
            {
                artifacts.add( artifact );
            }
            else if ( getLog().isDebugEnabled() )
            {
                getLog().debug( "Got null CheckstylePlugin Dependency
Artifact from key ["
                        + depKey + "]. Excluding null Artifact from
return List. " );
            }
        }
    }
    return artifacts;
}


--
+==============================+
| Bästa hälsningar,
| [sw. "Best regards"]
|
| Lennart Jörelid
| EAI Architect & Integrator
|
| jGuru Europe AB
| Mölnlycke - Kista
|
| Email: lj@jguru.se
| URL:   www.jguru.se
| Phone
| (skype):    jgurueurope
| (intl):     +46 708 507 603
| (domestic): 0708 - 507 603
+==============================+

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message