Commits

Anonymous committed 2d14d2c

Tutorial sweep update

  • Participants
  • Parent commits 8b33e11

Comments (0)

Files changed (12)

-<?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/maven-v4_0_0.xsd">
-
-    <modelVersion>4.0.0</modelVersion>
-    <groupId>com.atlassian.plugins.tutorial</groupId>
-    <artifactId>jira-menu-items</artifactId>
-    <version>1.0</version>
-
-    <organization>
-        <name>Example Company</name>
-        <url>http://www.example.com/</url>
-    </organization>
-
-    <name>jira-menu-items</name>
-    <description>This plugin adds a new section and items to JIRA's menu</description>
-    <packaging>atlassian-plugin</packaging>
-
-    <dependencies>
-        <dependency>
-            <groupId>com.atlassian.jira</groupId>
-            <artifactId>atlassian-jira</artifactId>
-            <version>${jira.version}</version>
-            <scope>provided</scope>
-        </dependency>        
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.6</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.atlassian.jira</groupId>
-            <artifactId>jira-func-tests</artifactId>
-            <version>${jira.version}</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>com.atlassian.maven.plugins</groupId>
-                <artifactId>maven-jira-plugin</artifactId>
-                <version>3.0.5</version>
-                <extensions>true</extensions>
-                <configuration>
-                    <productVersion>${jira.version}</productVersion>
-                    <productDataVersion>${jira.data.version}</productDataVersion>
-                </configuration>
-            </plugin>
-            <plugin>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>1.5</source>
-                    <target>1.5</target>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-    <properties>
-        <jira.version>4.0.1</jira.version>
-        <jira.data.version>4.0</jira.data.version>
-    </properties>
-
-</project>
+<?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/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.atlassian.plugins.tutorial</groupId>
+    <artifactId>jira-menu-items</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <organization>
+        <name>Example Company</name>
+        <url>http://www.example.com/</url>
+    </organization>
+
+    <name>jira-menu-items</name>
+    <description>This plugin adds a new section and items to JIRA's menu</description>
+    <packaging>atlassian-plugin</packaging>
+
+    <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>
+
+        <!-- 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>
+
+		<!-- 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>
+					<!-- 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>
+					-->
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <properties>
+        <jira.version>6.1-20130626</jira.version>
+        <amps.version>4.2.0</amps.version>
+        <plugin.testrunner.version>1.1.1</plugin.testrunner.version>
+		<!-- TestKit version 5.x for JIRA 5.x, 6.x for JIRA 6.x -->
+		<testkit.version>5.2.26</testkit.version>
+    </properties>
+
+</project>

File src/main/java/com/atlassian/plugins/tutorial/MyPluginComponent.java

+package com.atlassian.plugins.tutorial;
+
+public interface MyPluginComponent
+{
+    String getName();
+}

File src/main/java/com/atlassian/plugins/tutorial/MyPluginComponentImpl.java

+package com.atlassian.plugins.tutorial;
+
+import com.atlassian.sal.api.ApplicationProperties;
+
+public class MyPluginComponentImpl implements MyPluginComponent
+{
+    private final ApplicationProperties applicationProperties;
+
+    public MyPluginComponentImpl(ApplicationProperties applicationProperties)
+    {
+        this.applicationProperties = applicationProperties;
+    }
+
+    public String getName()
+    {
+        if(null != applicationProperties)
+        {
+            return "myComponent:" + applicationProperties.getDisplayName();
+        }
+        
+        return "myComponent";
+    }
+}

File src/main/resources/atlassian-plugin.xml

-<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.artifactId}" plugins-version="2">
-    <plugin-info>
-        <description>${project.description}</description>
-        <version>${project.version}</version>
-        <vendor name="${project.organization.name}" url="${project.organization.url}" />
-    </plugin-info>
-		
-    <web-section key="my_links_section" name="My Links Main Section" location="my_links_link" weight="10"/>
-		
-    <web-item key="my_links_link" name="Link on My Links Main Section" section="system.top.navigation.bar" weight="47">
-        <label>My Company</label>
-        <link linkId="my_links_link">http://www.atlassian.com</link>
-    </web-item>
-
-    <web-item key="website_link" name="Company Web Site" section="my_links_link/my_links_section" weight="10">
-        <label>Web Site</label>
-        <link linkId="website_link">http://www.atlassian.com</link>
-    </web-item>
-				
-    <web-item key="documentation_link" name="Documentation Web Site" section="my_links_link/my_links_section" weight="10">
-        <label>Documentation</label>
-        <link linkId="documentation_link">http://confluence.atlassian.com</link>
-    </web-item>
-		
-</atlassian-plugin>
+<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
+    <plugin-info>
+        <description>${project.description}</description>
+        <version>${project.version}</version>
+        <vendor name="${project.organization.name}" url="${project.organization.url}" />
+        <param name="plugin-icon">images/pluginIcon.png</param>
+        <param name="plugin-logo">images/pluginLogo.png</param>
+    </plugin-info>
+
+    <!-- add our i18n resource -->
+    <resource type="i18n" name="i18n" location="jira-menu-items"/>
+    
+    <!-- add our web resources -->
+    <web-resource key="jira-menu-items-resources" name="jira-menu-items Web Resources">
+        <dependency>com.atlassian.auiplugin:ajs</dependency>
+        
+        <resource type="download" name="jira-menu-items.css" location="/css/jira-menu-items.css"/>
+        <resource type="download" name="jira-menu-items.js" location="/js/jira-menu-items.js"/>
+        <resource type="download" name="images/" location="/images"/>
+
+        <context>jira-menu-items</context>
+    </web-resource>
+      
+    <!-- publish our component -->
+    <component key="myPluginComponent" class="com.atlassian.plugins.tutorial.MyPluginComponentImpl" public="true">
+        <interface>com.atlassian.plugins.tutorial.MyPluginComponent</interface>
+    </component>
+    
+    <!-- import from the product container -->
+    <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" />
+    
+    <web-section key="my_links_section" name="My Links Main Section" location="my_links_link" weight="10"/>
+
+    <web-item key="my_links_link" name="Link on My Links Main Section" section="system.top.navigation.bar" weight="47">
+       <label>My Company</label>
+       <link linkId="my_links_link">http://www.atlassian.com</link>
+    </web-item>
+
+    <web-item key="website_link" name="Company Web Site" section="my_links_link/my_links_section" weight="10">
+        <label>Web Site</label>
+        <link linkId="website_link">http://www.atlassian.com</link>
+    </web-item>
+
+    <web-item key="documentation_link" name="Documentation Web Site" section="my_links_link/my_links_section" weight="10">
+        <label>Documentation</label>
+        <link linkId="documentation_link">http://confluence.atlassian.com</link>
+    </web-item>
+
+</atlassian-plugin>

File src/main/resources/css/jira-menu-items.css

Empty file added.

File src/main/resources/images/pluginIcon.png

Added
New image

File src/main/resources/images/pluginLogo.png

Added
New image

File src/main/resources/jira-menu-items.properties

+#put any key/value pairs here
+my.plugin.name=MyPlugin

File src/main/resources/js/jira-menu-items.js

Empty file added.

File src/test/java/it/com/atlassian/plugins/tutorial/MyComponentWiredTest.java

+package it.com.atlassian.plugins.tutorial;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import com.atlassian.plugins.osgi.test.AtlassianPluginsTestRunner;
+import com.atlassian.plugins.tutorial.MyPluginComponent;
+import com.atlassian.sal.api.ApplicationProperties;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(AtlassianPluginsTestRunner.class)
+public class MyComponentWiredTest
+{
+    private final ApplicationProperties applicationProperties;
+    private final MyPluginComponent myPluginComponent;
+
+    public MyComponentWiredTest(ApplicationProperties applicationProperties,MyPluginComponent myPluginComponent)
+    {
+        this.applicationProperties = applicationProperties;
+        this.myPluginComponent = myPluginComponent;
+    }
+
+    @Test
+    public void testMyName()
+    {
+        assertEquals("names do not match!", "myComponent:" + applicationProperties.getDisplayName(),myPluginComponent.getName());
+    }
+}

File src/test/java/ut/com/atlassian/plugins/tutorial/MyComponentUnitTest.java

+package ut.com.atlassian.plugins.tutorial;
+
+import org.junit.Test;
+import com.atlassian.plugins.tutorial.MyPluginComponent;
+import com.atlassian.plugins.tutorial.MyPluginComponentImpl;
+
+import static org.junit.Assert.assertEquals;
+
+public class MyComponentUnitTest
+{
+    @Test
+    public void testMyName()
+    {
+        MyPluginComponent component = new MyPluginComponentImpl(null);
+        assertEquals("names do not match!", "myComponent",component.getName());
+    }
+}

File src/test/resources/atlassian-plugin.xml

+<atlassian-plugin key="${project.groupId}.${project.artifactId}-tests" name="${project.name}" plugins-version="2">
+    <plugin-info>
+        <description>${project.description}</description>
+        <version>${project.version}</version>
+        <vendor name="${project.organization.name}" url="${project.organization.url}" />
+    </plugin-info>
+
+    <!-- from our base plugin -->
+    <component-import key="myComponent" interface="com.atlassian.plugins.tutorial.MyPluginComponent"/>
+
+    <!-- from the product container -->
+    <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" />
+    
+</atlassian-plugin>