Properly add an external jar to a plugin, both compile/build-time

tkhduracell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 6, 2012

How do I properly bundle a single jar to my plugin.
I'm building a TFS-repomodule to Bamboo, and I want to use the .jar Microsoft provided. But I'm getting a ClassNotFound-exeption.

Stack trace:

com.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.NoClassDefFoundError: com/microsoft/tfs/core/clients/versioncontrol/specs/version/VersionSpec
	at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:152)
	at com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:115)
	at com.atlassian.bamboo.repository.RepositoryDataImpl.getRepository(RepositoryDataImpl.java:136)
	at com.atlassian.bamboo.build.creation.RepositoryConfigHelper.extractRepositoriesFromConfiguration(RepositoryConfigHelper.java:234)
.....
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: com/microsoft/tfs/core/clients/versioncontrol/specs/version/VersionSpec
	at com.company.bamboo.plugins.tfs.TFSRepository.populateFromConfig(TFSRepository.java:124)
	at com.atlassian.bamboo.repository.RepositoryReference.create(RepositoryReference.java:27)
	at com.atlassian.bamboo.repository.RepositoryReference.create(RepositoryReference.java:8)
	at com.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:326)
	at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:146)
	... 235 more
Caused by: java.lang.ClassNotFoundException: com.microsoft.tfs.core.clients.versioncontrol.specs.version.VersionSpec
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
	... 240 more

I've tried to add the jar in maven / OSGi. (Since WEB-INF/libs is deprecated, right?)

pom.xml

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company.bamboo</groupId>
    <artifactId>atlassian-bamboo-plugin-tfs</artifactId>
    <version>0.0.2</version>

    <organization>
        <name>Company</name>
        <url>http://www.company.com/</url>
    </organization>

    <name>TFS Repository Plugin</name>
    <description>Plugin to provide TFS support</description>
    <packaging>atlassian-plugin</packaging>

    <dependencies>
        .....
        <dependency>
            <groupId>com.microsoft.tfs</groupId>
            <artifactId>tfssdk</artifactId>
            <version>10.1.0</version>
            <scope>system</scope><!-- Here! -->
            <systemPath>${basedir}/libs/com.microsoft.tfs.sdk-10.1.0.jar</systemPath>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>...</resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-bamboo-plugin</artifactId>
                <version>3.7</version>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${bamboo.version}</productVersion>
                    <productDataVersion>${bamboo.data.version}</productDataVersion>
                    <instructions>
                        <Import-Package>
                            com.microsoft.tfs*;version="0.0"  <!-- Here! -->
                        </Import-Package>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                ...
            </plugin>

            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>system</includeScope>
                            <outputDirectory>${build.outputDirectory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin></plugins>
    </build>
    <properties>
        <maven.local.repo>C:\Program Files (x86)\Atlassian\atlassian-plugin-sdk-3.10.4\repository</maven.local.repo>        
        <bamboo.version>4.1-rc2</bamboo.version>
        <bamboo.data.version>3.2.2</bamboo.data.version>
    </properties>

    <distributionManagement>
        <repository>
            <id>atlassian-contrib</id>
            <name>Atlassian Contrib Repository</name>
        </repository>...
    </distributionManagement>
  
    <repositories>
        <repository>
            <id>atlassian</id>
            <name>Atlassian Repository</name>
            <url>https://maven.atlassian.com/content/groups/public/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>

        <repository>
            <id>libs</id>
            <name>libs</name>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>ignore</checksumPolicy>
            </releases>
            <url>file://${project.basedir}/libs</url>
        </repository>
    </repositories>
 
    <pluginRepositories>
        <pluginRepository>
            <id>atlassian-public</id>
            <url>https://m2proxy.atlassian.com/repository/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
  
</project>

Any ideas???


3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
James Dumay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2012

The problem is the "system" scope of the tfssdk dependency. You need to remove the system scope and use the maven install plugin to install the tfssdk into your local repository.

The SDK build system will then automatically add the dependency to the plugin jar.

Interested that you are building TFS support for Bamboo! I'd love to get in touch with you about it - could you send me an email at james@atlassian.com ?

tkhduracell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2012

Which <scope> is proper then? Compile?

James Dumay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 11, 2012

Yes, use the compile scope. Compile is the default scope if you don't specify one.

0 votes
tkhduracell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 21, 2012

Yes, we did finnish it. We added full integration with TFS, but we didn't get it to work with the JavaTFS-SDK. We wrote a wrapper.jar that imitates tfs.exe and then we call this .jar via commandline from our TFS-sourceplugin in Bamboo to get history and files.

0 votes
Joshua Taurek September 20, 2012

Did you ever get this plugin completed? I am trying to do a similar thing and integrate TFS as a source code repository.

TAGS
AUG Leaders

Atlassian Community Events