Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting errors in the .java file while creating due-date-indicator plugin?

vikram ummagani October 23, 2017

Hi Team,

I am trying to create a due-date-indicator plugin. I have imported a project in my eclipse. It contains .java file which is named as DueDateIndicator.java. I got lot of errors when I first see the java file. I had solved some of those errors putting required import statements for them in the .java file. But when it comes to lines 1)@ComponentImport  (i.e. error showing in the eclipse is "ComponentImport cannot be resolved to a type") and 2)  public Map getContextMap(User user, JiraHelper jiraHelper)  (i.e. indicating error at User and the error reason it showing in the eclipse "User cannot be resolved to a type") , I am unable to resolve these errors in the eclipse IDE. Please mention the modifications which I should do, to remove these errors.

My DueDateIndicator.java file:

package com.example.plugins.tutorial;

import com.atlassian.jira.user.ApplicationUser;

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.plugin.webfragment.contextproviders.AbstractJiraContextProvider;
import com.atlassian.jira.plugin.webfragment.model.JiraHelper;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;
import java.io.*;
import java.lang.*;

@ComponentImport
public class DueDateIndicator extends AbstractJiraContextProvider
{
private static final int MILLIS_IN_DAY = 24 * 60 * 60 * 1000;

@Override
public Map getContextMap(User user, JiraHelper jiraHelper) {
Map contextMap = new HashMap();
Issue currentIssue = (Issue) jiraHelper.getContextParams().get("issue");
Timestamp dueDate = currentIssue.getDueDate();
if (dueDate != null)
{
int currentTimeInDays = (int) (System.currentTimeMillis() / MILLIS_IN_DAY);
int dueDateTimeInDays = (int) (dueDate.getTime() / MILLIS_IN_DAY);

int daysAwayFromDueDateCalc = dueDateTimeInDays - currentTimeInDays + 1;
contextMap.put("daysAwayFromDueDate", daysAwayFromDueDateCalc);
}
return contextMap;
}

@Override
public Map getContextMap(ApplicationUser arg0, JiraHelper arg1) {
//TODO Auto-generated method stub
return null;
}



}


My atlassian-plugin.xml file:

<?xml version="1.0" encoding="UTF-8"?>

<atlassian-plugin key="${atlassian.plugin.key}" 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/google image.png</param>
<param name="plugin-logo">images/google image.png</param>
</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="jws"/>
<web-item key="jtricks-admin-link" name="JTricks Link" section="system.top.navigation.bar" i18n-name-key="webfragments.admin.jtricks.item" weight="10">
<label>Links</label>
<link linkId="jtricks.admin.link">http://www.j-tricks.com</link>
</web-item>
<web-section key="jtricks-admin-section" name="JTricks Section" location="jtricks.admin.link" i18n-name-key="webfragments.admin.jtricks.section" weight="900">
<label>itsm</label>
<description>J Tricks Section Descitption</description>
<tooltip>J Tricks - Little JIRA Tricks</tooltip>
</web-section>

<web-item key="jtricks-user-link" name="JTricks user Link" section="jtricks.admin.link/jtricks-admin-section" i18n-name-key="webfragments.admin.jtricks.item" weight="10">
<label>google</label>
<link linkId="jtricks.admin.link">https://www.google.com</link>
<icon height="16" width="16">
<!-- <link>http://www.gravatar.com/avatar/64e1b8d34f425d19e1ee2ea7236d3028?d=mm&amp;s=24</link>-->
<!-- <link>/secure/projectavatar?pid=10000&amp;amp;size=large&amp;amp;avatarId=10500</link>-->
<link>http://192.168.1.56:2990/jira/secure/attachment/10000/google_image.png&amp;amp;size=small&amp;amp;</link>
</icon>
</web-item>

 

</atlassian-plugin>

My pom.xml file:

<?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.example.plugins.tutorial</groupId>
<artifactId>duedate</artifactId>
<version>1.0-SNAPSHOT</version>
<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>
<name>duedate</name>
<description>This is the com.example.plugins.tutorial:duedate plugin for Atlassian JIRA.</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>com.atlassian.sal</groupId>
<artifactId>sal-api</artifactId>
<version>2.0.0</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>provided</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>


<!-- 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>
-->


<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>


</dependencies>
<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>${project.version}</version>
</plugin>

<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>
-->
<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>com.example.plugins.tutorial.api,</Export-Package>
<!-- Add package import here -->
<Import-Package>org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;resolution:="optional", *</Import-Package>
<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>

<!-- added by me -->
<!-- <instructions>
<Atlassian-Plugin-Key>com.atlassian.plugin.DueDateIndicator</Atlassian-Plugin-Key>
<Spring-Context>*</Spring-Context>
<Export-Package>
</Export-Package>
<Import-Package>
*
</Import-Package>
</instructions>
<skipManifestValidation>true</skipManifestValidation> -->

<!-- added by me -->


</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>

<!-- added by me -->
</plugins>
</build>
<properties>
<jdkLevel>1.8</jdkLevel>
<jira.version>7.5.0</jira.version>
<amps.version>6.2.11</amps.version>
<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
<productVersion>6.2.14</productVersion>
<!-- <amps.version>4.1</amps.version>
<plugin.testrunner.version>1.1</plugin.testrunner.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>
</project>

Versions I am using: Apache Maven is 3.2.1, Atlas is 6.2.14, java is 1.8, jira is 7.2.2
Please help me.

Thanks in advance
Vikram  

 

1 answer

0 votes
Andrew Moulton May 14, 2020

At a quick glance that looks fine, but do you see any warnings or errors when you run "atlas-mvn eclipse:eclipse"?  Maybe it wasn't able to download the packages for some reason (server down, no internet, or maybe a certificate issue).  

For example, if you're running this inside a Virtual Machine on a Company laptop that is using NetSkope, you need to add the NS-Root certificates for it into your keystore (Java).

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira cloud certification, managing jira projects, jira project administration, jira cloud exam, atlassian certification, agile project management, jira workflows, jira permissions, jira training, jira cloud skills, atlassian learning

Become a Certified Jira Service Project Expert 🦸🏻‍♂️

Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.

Get Certified! ✍️
AUG Leaders

Atlassian Community Events