Need help configuring the pom.xml so I can have integration tests

32 views
Skip to first unread message

Claudiu Guiman

unread,
Jan 9, 2017, 12:32:43 PM1/9/17
to jenkin...@googlegroups.com

Hi,
I’m trying to add integration tests in my plugin and I want them to be optional and only be triggered if you run a specific maven step.
To accomplish this I added a dependency to the maven failsafe plugin and now I need to run “mvn failsafe:integration-test” to run my specific integration tests.
So far so good, but when I need to execute some code that depends on jenkins I’m getting NoClassDefFoundError exceptions. I managed to fix some of these by adding a dependency to the jenkins-test-harness, but now I’m hitting one I can’t fix: “java.lang.NoClassDefFoundError: com/google/common/reflect/TypeToken”. The exception is due to the fact that I don’t have a direct dependency to google guava, but the jenkins-core should bring that into my classpath, but even if I add the jenkins-core as a dependency within the “test” scope I can’t manage to fix it.
Here’s the pom file portion in question:
<dependency>

        <groupId>org.jenkins-ci.main</groupId>

        <artifactId>jenkins-test-harness</artifactId>

        <scope>test</scope>

</dependency>

<dependency>

        <groupId>org.jenkins-ci.main</groupId>

        <artifactId>jenkins-core</artifactId>

        <scope>provided</scope>

</dependency>

 

I’m using “provided” scope right now because that’s what Maven recommends: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
Can someone help me understand what I’m doing wrong and how I should fix the pom file?

Thanks,
Claudiu

Claudiu Guiman

unread,
Jan 10, 2017, 2:22:55 PM1/10/17
to jenkin...@googlegroups.com

Managed to fix it.
A project dependency was requiring guava 18.0, but jenkis-core was fetching 11.0.1. To fix it I had to exclude guava from jenkins-core:
    <dependency>

        <groupId>org.jenkins-ci.main</groupId>

        <artifactId>jenkins-core</artifactId>

        <exclusions>

            <exclusion>

                <groupId>com.google.guava</groupId>

                <artifactId>guava</artifactId>

            </exclusion>

        </exclusions>

        <scope>provided</scope>

    </dependency>

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CY1PR0301MB1660D6BE07AB975399F2AFD2D7640%40CY1PR0301MB1660.namprd03.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages