Problem with implementing UPM support into add-on

Once again I am back with questions and am hoping someone here can help me out.

I’ve been preparing my add-on for the marketplace and have been following this tutorial while doing it: https://developer.atlassian.com/platform/marketplace/ommitting-web-resources-for-unlicensed-server-apps/ but I seem to have once again hit upon a wall I can’t get past.

I’ve been following the tutorial (which I’m implementing in my own add-on) bu no matter what I do the add-on doesn’t work when I try to test it. Can someone point me to what I’m doing wrong?

ConditionEvaluator

public interface ConditionEvaluator
{
    public boolean evaluate(ConditionType type);
}

ConditionEvaluatorImpl

import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.upm.api.license.PluginLicenseManager;
import com.atlassian.upm.api.license.entity.PluginLicense;

import javax.inject.Inject;

@Scanned
public class ConditionEvaluatorImpl implements ConditionEvaluator
{
    @ComponentImport
    PluginLicenseManager licenseManager;

    @Inject
    public ConditionEvaluatorImpl(final PluginLicenseManager licenseManager)
    {
        this.licenseManager = licenseManager;
    }

    @Override
    public boolean evaluate(ConditionType type)
    {
        switch (type)
        {
            case LICENSED:
                return isLicenseValid();
            default:
                return false;
        }
    }
    private boolean isLicenseValid()
    {
        boolean isLicensed = false;
        boolean hasErrors = false;
        for (PluginLicense pluginLicense : licenseManager.getLicense())
        {
            isLicensed = true;
            hasErrors = hasErrors || pluginLicense.getError().isDefined();
        }
        isLicensed = isLicensed && !hasErrors;
        return isLicensed;
    }
}

ConditionType

public enum ConditionType
{
    LICENSED
}

IsPluginLicensedCondition

import com.atlassian.plugin.webresource.condition.SimpleUrlReadingCondition;

public class IsPluginLicensedCondition extends SimpleUrlReadingCondition
{
    private ConditionEvaluator conditionEvaluator;

    public IsPluginLicensedCondition(final ConditionEvaluator conditionEvaluator)
    {
        this.conditionEvaluator = conditionEvaluator;
    }

    @Override
    protected boolean isConditionTrue()
    {
        return conditionEvaluator.evaluate(ConditionType.LICENSED);
    }

    @Override
    protected String queryKey()
    {
        // This string will be appended to URLs as a GET parameter
        // whenever 'isConditionTrue' returns true.
        // You should make the string short, but unique to your app.
        return "myPluginName";
    }
}

atlassian-plugin.xml


  <plugin-info>
    <version>${project.version}</version>
    <param name="atlassian-licensing-enabled">true</param>
    <vendor name="${project.organization.name}" url="${project.organization.url}"/>
  </plugin-info>

<web-resource key="tigSearchbarExtension-resources" name="tigSearchbarExtension Web Resources">
    <condition class="tig.jira.extension.tigSearchbarExtension.service.IsPluginLicensedCondition"/>
    <dependency>com.atlassian.auiplugin:ajs</dependency>
    <resource type="download" name="tigSearchbarExtension.js" location="/js/tigSearchbarExtension.js"/>
    <resource type="download" name="searchBar.css" location="/css/searchBar.css"/>
    <resource type="download" name="images/" location="/images"/>
  </web-resource>

pom.xml

<dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
        <!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
        <!--
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-core</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>
        -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-runtime</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <scope>provided</scope>
        </dependency>

        <!-- Licensing
        <dependency>
            <groupId>com.atlassian.upm</groupId>
            <artifactId>licensing-api</artifactId>
            <version>2.21.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.upm</groupId>
            <artifactId>upm-api</artifactId>
            <version>2.21</version>
            <scope>provided</scope>
        </dependency>-->

        <!-- WIRED TEST RUNNER DEPENDENCIES -->
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
            <version>${plugin.testrunner.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2-atlassian-1</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource-api</artifactId>
            <version>3.5.39</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.upm</groupId>
            <artifactId>upm-api</artifactId>
            <version>2.21</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.upm</groupId>
            <artifactId>licensing-api</artifactId>
            <version>2.21.4</version>
        </dependency>

        <!-- Uncomment to use TestKit in your project. Details at https://bitbucket.org/atlassian/jira-testkit -->
        <!-- You can read more about TestKit at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter+integration+testing+with+TestKit -->
        <!--
        <dependency>
            <groupId>com.atlassian.jira.tests</groupId>
            <artifactId>jira-testkit-client</artifactId>
            <version>${testkit.version}</version>
            <scope>test</scope>
        </dependency>
        -->
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-jira-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${jira.version}</productVersion>
                    <productDataVersion>${jira.version}</productDataVersion>
                    <productDataPath>${project.basedir}/src/test/resources/generated-test-resources.zip</productDataPath>
                    <applications>
                        <application>
                            <applicationKey>jira-servicedesk</applicationKey>
                            <version>${jira.servicedesk.application.version}</version>
                        </application>
                    </applications>
                    <!-- Uncomment to install TestKit backdoor in JIRA. -->
                    <!--
                    <pluginArtifacts>
                        <pluginArtifact>
                            <groupId>com.atlassian.jira.tests</groupId>
                            <artifactId>jira-testkit-plugin</artifactId>
                            <version>${testkit.version}</version>
                        </pluginArtifact>
                    </pluginArtifacts>
                    -->
                    <enableQuickReload>true</enableQuickReload>
                    <enableFastdev>false</enableFastdev>

                    <!-- See here for an explanation of default instructions: -->
                    <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <!-- Add package to export here -->
                        <Export-Package>
                            tig.jira.extension.tigSearchbarExtension.api,
                        </Export-Package>

                        <!-- Add package import here -->
                        <Import-Package>org.springframework.osgi.*;resolution:="optional",
                            org.eclipse.gemini.blueprint.*;resolution:="optional",
                            avax.ws.rs*;version="[1,2)",
                            javax.servlet*;version="2.5",
                            javax.xml.bind*;version="[2.1,3)",
                            *;version="0";resolution:=optional, *</Import-Package>
                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <version>${atlassian.spring.scanner.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <scannedDependencies>
                        <dependency>
                            <groupId>com.atlassian.plugin</groupId>
                            <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                        </dependency>
                    </scannedDependencies>
                    <verbose>false</verbose>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <jira.version>7.2.2</jira.version>
        <amps.version>6.2.11</amps.version>
        <plugin.testrunner.version>1.2.3</plugin.testrunner.version>
        <jira.servicedesk.application.version>3.2.2</jira.servicedesk.application.version>
        <atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
        <!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <!-- TestKit version 6.x for JIRA 6.x -->
        <testkit.version>6.3.11</testkit.version>
    </properties>

I still can’t figure out what I’m doing wrong here. The error I keep getting is:

[INFO] [talledLocalContainer] 2017-12-21 11:32:53,884 QuickReload - Plugin Installer ERROR      [c.a.plugin.manager.DefaultPluginManager] There was an error loading the descriptor 'tigSearchbarExtension Web Resources' of plugin 'tig.jira.extension.tigSearchbarExtension'. Disabling.
[INFO] [talledLocalContainer] java.lang.RuntimeException: Unable to enable web resource due to issue processing condition
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.webresource.WebResourceModuleDescriptor.parseCondition(WebResourceModuleDescriptor.java:208)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.webresource.WebResourceModuleDescriptor.enabled(WebResourceModuleDescriptor.java:183)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.manager.DefaultPluginManager.notifyModuleEnabled(DefaultPluginManager.java:1991)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.manager.DefaultPluginManager.enableConfiguredPluginModule(DefaultPluginManager.java:1738)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.manager.DefaultPluginManager.enableConfiguredPluginModules(DefaultPluginManager.java:1715)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1227)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1188)
[INFO] [talledLocalContainer] 	at com.atlassian.jira.plugin.JiraPluginManager.addPlugins(JiraPluginManager.java:150)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.manager.DefaultPluginManager.scanForNewPlugins(DefaultPluginManager.java:903)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.manager.DefaultPluginManager.installPlugins(DefaultPluginManager.java:821)
[INFO] [talledLocalContainer] 	at com.atlassian.jira.plugin.JiraPluginManager.installPlugins(JiraPluginManager.java:168)
[INFO] [talledLocalContainer] 	... 2 filtered
[INFO] [talledLocalContainer] 	at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
[INFO] [talledLocalContainer] 	at com.sun.proxy.$Proxy122.installPlugins(Unknown Source)
[INFO] [talledLocalContainer] 	... 2 filtered
[INFO] [talledLocalContainer] 	at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] [talledLocalContainer] 	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
[INFO] [talledLocalContainer] 	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
[INFO] [talledLocalContainer] 	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[INFO] [talledLocalContainer] 	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
[INFO] [talledLocalContainer] 	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[INFO] [talledLocalContainer] 	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
[INFO] [talledLocalContainer] 	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[INFO] [talledLocalContainer] 	at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[INFO] [talledLocalContainer] 	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
[INFO] [talledLocalContainer] 	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[INFO] [talledLocalContainer] 	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
[INFO] [talledLocalContainer] 	at com.sun.proxy.$Proxy912.installPlugins(Unknown Source)
[INFO] [talledLocalContainer] 	at com.atlassian.labs.plugins.quickreload.install.PluginInstallerMechanic.installPluginImmediately(PluginInstallerMechanic.java:185)
[INFO] [talledLocalContainer] 	at com.atlassian.labs.plugins.quickreload.install.PluginInstaller.installPluginImmediately(PluginInstaller.java:318)
[INFO] [talledLocalContainer] 	at com.atlassian.labs.plugins.quickreload.install.PluginInstaller.attemptInstall(PluginInstaller.java:308)
[INFO] [talledLocalContainer] 	at com.atlassian.labs.plugins.quickreload.install.PluginInstaller.loopWaitingForInstallPromises(PluginInstaller.java:232)
[INFO] [talledLocalContainer] 	at com.atlassian.labs.plugins.quickreload.install.PluginInstaller.access$000(PluginInstaller.java:36)
[INFO] [talledLocalContainer] 	at com.atlassian.labs.plugins.quickreload.install.PluginInstaller$1.run(PluginInstaller.java:75)
[INFO] [talledLocalContainer] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[INFO] [talledLocalContainer] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[INFO] [talledLocalContainer] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[INFO] [talledLocalContainer] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[INFO] [talledLocalContainer] 	at java.lang.Thread.run(Thread.java:748)
[INFO] [talledLocalContainer] Caused by: com.atlassian.plugin.PluginParseException: Configured condition class does not implement the Condition interface
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.webresource.condition.UrlReadingConditionElementParser.makeConditionImplementation(UrlReadingConditionElementParser.java:62)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.webresource.condition.UrlReadingConditionElementParser.makeConditionImplementation(UrlReadingConditionElementParser.java:43)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.web.baseconditions.AbstractConditionElementParser.makeCondition(AbstractConditionElementParser.java:116)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.web.baseconditions.AbstractConditionElementParser.makeConditions(AbstractConditionElementParser.java:100)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.web.baseconditions.AbstractConditionElementParser.makeConditions(AbstractConditionElementParser.java:57)
[INFO] [talledLocalContainer] 	... 46 more
[INFO] [talledLocalContainer] Caused by: java.lang.ClassCastException: tig.jira.extension.tigSearchbarExtension.IsPluginLicensedCondition cannot be cast to com.atlassian.plugin.web.Condition
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.webresource.condition.UrlReadingConditionElementParser.create(UrlReadingConditionElementParser.java:77)
[INFO] [talledLocalContainer] 	at com.atlassian.plugin.webresource.condition.UrlReadingConditionElementParser.makeConditionImplementation(UrlReadingConditionElementParser.java:60)
[INFO] [talledLocalContainer] 	... 51 more