New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException: RedundantDependencyVersionsRule with maven expressions #4

Closed
lkwg82 opened this Issue Aug 23, 2013 · 8 comments

Comments

Projects
None yet
3 participants
@lkwg82
Contributor

lkwg82 commented Aug 23, 2013

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!

lewisd32 added a commit that referenced this issue Aug 25, 2013

@lewisd32

This comment has been minimized.

Show comment
Hide comment
@lewisd32

lewisd32 Aug 25, 2013

Owner

This should be fixed now, in 0.0.8-SNAPSHOT. (You'll need to build it yourself though, it's not deployed anywhere).
I'll do another release once I'm able to merge in your new rules.

Owner

lewisd32 commented Aug 25, 2013

This should be fixed now, in 0.0.8-SNAPSHOT. (You'll need to build it yourself though, it's not deployed anywhere).
I'll do another release once I'm able to merge in your new rules.

@lkwg82

This comment has been minimized.

Show comment
Hide comment
@lkwg82

lkwg82 Aug 25, 2013

Contributor

I can confirm!

Contributor

lkwg82 commented Aug 25, 2013

I can confirm!

@lkwg82 lkwg82 closed this Aug 25, 2013

@Stephan202

This comment has been minimized.

Show comment
Hide comment
@Stephan202

Stephan202 Oct 28, 2013

Contributor

It seems this issue isn't fixed completely, at least when using ${project.version} and/or ${project.groupId}:

[INFO] --- lint-maven-plugin:0.0.8:check (validate-pom) @ bulgarian-stemmer ---
 WARN [RedundantDependencyVersionsRule:81] 2013-10-28 08:47:47,500 - java.lang.IllegalStateException: Could not resolve Dependency {groupId=${project.groupId}, artifactId=engine, version=null, type=jar} using path dependencies[groupId='${project.groupId}' and artifactId='engine' and type='jar']
 WARN [RedundantDependencyVersionsRule:81] 2013-10-28 08:47:47,512 - java.lang.IllegalStateException: Could not resolve Dependency {groupId=${project.groupId}, artifactId=engine, version=${project.version}, type=jar} using path dependencyManagement/dependencies[groupId='${project.groupId}' and artifactId='engine' and type='jar']
Contributor

Stephan202 commented Oct 28, 2013

It seems this issue isn't fixed completely, at least when using ${project.version} and/or ${project.groupId}:

[INFO] --- lint-maven-plugin:0.0.8:check (validate-pom) @ bulgarian-stemmer ---
 WARN [RedundantDependencyVersionsRule:81] 2013-10-28 08:47:47,500 - java.lang.IllegalStateException: Could not resolve Dependency {groupId=${project.groupId}, artifactId=engine, version=null, type=jar} using path dependencies[groupId='${project.groupId}' and artifactId='engine' and type='jar']
 WARN [RedundantDependencyVersionsRule:81] 2013-10-28 08:47:47,512 - java.lang.IllegalStateException: Could not resolve Dependency {groupId=${project.groupId}, artifactId=engine, version=${project.version}, type=jar} using path dependencyManagement/dependencies[groupId='${project.groupId}' and artifactId='engine' and type='jar']
@lkwg82

This comment has been minimized.

Show comment
Hide comment
@lkwg82

lkwg82 Oct 28, 2013

Contributor

Hi,

can you give a sample pom.xml and the complete call, plz

Cheers Lars

Contributor

lkwg82 commented Oct 28, 2013

Hi,

can you give a sample pom.xml and the complete call, plz

Cheers Lars

@Stephan202

This comment has been minimized.

Show comment
Hide comment
@Stephan202

Stephan202 Oct 28, 2013

Contributor

Hi Lars,

I tried to find a minimal example. I can reproduce it by running mvn lint:check on the following POM:

<?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>0.0.8</version>

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

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>lint-maven-plugin</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>${project.groupId}</groupId>
                <artifactId>lint-maven-plugin</artifactId>
                <version>${project.version}</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>
Contributor

Stephan202 commented Oct 28, 2013

Hi Lars,

I tried to find a minimal example. I can reproduce it by running mvn lint:check on the following POM:

<?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>0.0.8</version>

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

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>lint-maven-plugin</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>${project.groupId}</groupId>
                <artifactId>lint-maven-plugin</artifactId>
                <version>${project.version}</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>
@lewisd32

This comment has been minimized.

Show comment
Hide comment
@lewisd32

lewisd32 Oct 28, 2013

Owner

Yep, it looks like this isn't completely fixed. I may have to find a completely different approach for the bit of code that's causing this, as I'm not sure the current approach can be fixed.

Owner

lewisd32 commented Oct 28, 2013

Yep, it looks like this isn't completely fixed. I may have to find a completely different approach for the bit of code that's causing this, as I'm not sure the current approach can be fixed.

@lewisd32 lewisd32 reopened this Oct 28, 2013

@lkwg82

This comment has been minimized.

Show comment
Hide comment
@lkwg82

lkwg82 Oct 29, 2013

Contributor

I'll have a look into this.

Contributor

lkwg82 commented Oct 29, 2013

I'll have a look into this.

@lewisd32

This comment has been minimized.

Show comment
Hide comment
@lewisd32

lewisd32 Oct 29, 2013

Owner

Thanks Lars, appreciate it. If you want to discuss any potential solutions, I'd be happy to offer whatever insight I can.

The maven project exposes two models, the "original" model, which maps very closely to the pom.xml, and a resolved model, which has properties replaced (among other things). From what I remember, most rules walk the resolved model, so that they can see the resolved version number, for when the pom.xml has properties in . However, at some point (I don't remember why, at the moment) the plugin has to find the equivalent element in the original element, which is where this is failing.

Maybe the xml file location could be used to more accurately find the original element. Or, maybe it doesn't actually need to find the original element, since I can't remember right now why it was doing that.

Owner

lewisd32 commented Oct 29, 2013

Thanks Lars, appreciate it. If you want to discuss any potential solutions, I'd be happy to offer whatever insight I can.

The maven project exposes two models, the "original" model, which maps very closely to the pom.xml, and a resolved model, which has properties replaced (among other things). From what I remember, most rules walk the resolved model, so that they can see the resolved version number, for when the pom.xml has properties in . However, at some point (I don't remember why, at the moment) the plugin has to find the equivalent element in the original element, which is where this is failing.

Maybe the xml file location could be used to more accurately find the original element. Or, maybe it doesn't actually need to find the original element, since I can't remember right now why it was doing that.

lkwg82 added a commit to lkwg82/lint-maven-plugin that referenced this issue Oct 29, 2013

@lewisd32 lewisd32 closed this in 8e61f50 Nov 9, 2013

This was referenced Jan 22, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment