dependency version com.atlassian.templaterender

jacob delddd July 4, 2018

Is there an easy way to know the version of a dependency?

A lot of tutorials have outdated version dependencies, is there an easy way to fix this?

i can't seem to find the version of com.atlassian.templaterender. 

none of these seem to work: https://docs.atlassian.com/atlassian-template-renderer-api/?_ga=2.91240210.943847648.1530275796-1803789069.1528660614

Intellij keeps giving: 

Error:(16, 38) java: package com.atlassian.templaterenderer does not exist

Error:(37, 17) java: cannot find symbol
symbol: class TemplateRenderer
location: class com.ebo.plugins.plugins.refapp.MyPluginServlet

 

the tutorial:

https://developer.atlassian.com/server/framework/atlassian-sdk/create-a-gui-with-templates-and-aui/

 

 

2 answers

1 accepted

2 votes
Answer accepted
Alexey Matveev
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.
July 4, 2018

Hello,

I added this dependency and it worked fine:

<!-- https://mvnrepository.com/artifact/com.atlassian.templaterenderer/atlassian-template-renderer-api -->
<dependency>
<groupId>com.atlassian.templaterenderer</groupId>
<artifactId>atlassian-template-renderer-api</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>

Alexey Matveev
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.
July 5, 2018

try to do 

atlas-mvn clean

atlas-mvn package

or just

atlas-mvn clean package

jacob delddd July 5, 2018

i tried: atlas-mvn clean, atlas-mvn package, atlas-mvn clean package, atlas-run, atlas-mvn idea:idea, ...

Still it seems it can't find "import com.atlassian.templaterenderer.TemplateRenderer"

jacob delddd July 5, 2018

Class:

package com.aaaaa.plugins.plugins.refapp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URI;
import com.atlassian.sal.api.auth.LoginUriProvider;
import com.atlassian.sal.api.user.UserManager;
import com.atlassian.sal.api.user.UserProfile;
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import javax.inject.Inject;
import com.atlassian.templaterenderer.TemplateRenderer;

/*
The new contents of MyPluginServlet add import statements for UserManager and LoginUriProvider.
The class now checks to see if the user is logged in (if their username isn’t null).
If users aren’t logged in, sendRedirect will prompt the user to log in.
You haven’t yet added anything in MyPluginServlet.java corresponding to TemplateRenderer or PluginSettingsFactory.
You’ll add dependencies in future steps.
*/



@Scanned
public class MyPluginServlet extends HttpServlet{
private static final Logger log = LoggerFactory.getLogger(MyPluginServlet.class);
@ComponentImport
private final UserManager userManager;
@ComponentImport
private final LoginUriProvider loginUriProvider;
@ComponentImport
private final TemplateRenderer templateRenderer=null;

@Inject MyPluginServlet(UserManager userManager, LoginUriProvider loginUriProvider)
{
this.userManager = userManager;
this.loginUriProvider = loginUriProvider;
//this.templateRenderer = templateRenderer;
}

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
//*** These methods are deprecated ***
//String username = userManager.getRemoteUsername(request);
//if (username == null || !userManager.isSystemAdmin(username))

//*** These methods should return the desired result ***
UserProfile user = userManager.getRemoteUser(request);
Boolean isUserAdmin = userManager.isSystemAdmin(user.getUserKey());
String username = user.getUsername();

if(username == null || !isUserAdmin)
{
redirectToLogin(request,response);
return;
}
templateRenderer.render("admin.vm", response.getWriter());
}
private void redirectToLogin(HttpServletRequest request, HttpServletResponse response) throws IOException
{
response.sendRedirect(loginUriProvider.getLoginUri(getUri(request)).toASCIIString());
}
private URI getUri(HttpServletRequest request) {
StringBuffer builder = request.getRequestURL();
if (request.getQueryString() != null) {
builder.append("?");
builder.append((request.getQueryString()));
}
return URI.create((builder.toString()));
}
}

 POM:

<?xml version="1.0" encoding="UTF-8"?>
<!--jira versie op aaaaa server is 7.3.7 -->
<!-- volgorde van dependencies zijn belangerijk!! !-->
<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.aaaa.plugins</groupId>
<artifactId>sprintReader</artifactId>
<version>1.0.0-SNAPSHOT</version>

<organization>
<name>aaaaaaa</name>
<url>https://aaaaaaa/nl/node/35/</url>
</organization>

<name>sprintReader</name>
<description>This is the com.aaaa.plugins:sprintReader plugin for Atlassian Refapp.</description>
<packaging>atlassian-plugin</packaging>

<dependencies>


<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.atlassian.templaterenderer/atlassian-template-renderer-api -->

<dependency>
<groupId>com.atlassian.templaterenderer</groupId>
<artifactId>atlassian-template-renderer-api</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.atlassian.sal</groupId>
<artifactId>sal-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope> <!-- Uses the application's SAL instead of bundling it into the plugin. -->
</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>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</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>
<!--https://developer.atlassian.com/server/framework/atlassian-sdk/adding-sal-dependency/ ZELF TOEGEVOEGD-->




</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.atlassian.platform</groupId>
<artifactId>platform</artifactId>
<version>${platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.atlassian.platform</groupId>
<artifactId>third-party</artifactId>
<version>${platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>


</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-refapp-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${refapp.version}</productVersion>
<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.ebo.com.ebo.plugins.plugins.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>
</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>
</plugins>
</build>

<properties>
<platform.version>3.0.0</platform.version>
<refapp.version>3.3.6</refapp.version>
<amps.version>6.3.15</amps.version>
<plugin.testrunner.version>1.2.3</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>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

</project>

 atlassian-plugin.xml

<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/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>

<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="sprintReader"/>

<!-- add our web resources -->
<web-resource key="sprintReader-resources" name="sprintReader Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>

<resource type="download" name="sprintReader.css" location="/css/sprintReader.css"/>
<resource type="download" name="sprintReader.js" location="/js/sprintReader.js"/>
<resource type="download" name="images/" location="/images"/>

<context>sprintReader</context>
</web-resource>



<servlet name="adminUI" class="com.aaaa.plugins.plugins.refapp.MyPluginServlet" key="test">
<url-pattern>/test</url-pattern>
</servlet>


</atlassian-plugin>
Alexey Matveev
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.
July 5, 2018

It must be atlas-mvn eclipse:eclipse even if you use idea.

Anyway do you have this error only in IDE or you have this error in the terminal as well?

jacob delddd July 5, 2018

there is not really an error, because i don't use objects from that import. 

But if i uncheck the objects from that import, then i get errors in both intellij and the terminal

jacob delddd July 5, 2018

terminal:  [INFO] atlassian-template-renderer-api-2.1.0.jar already exists in destination.

jacob delddd July 5, 2018

Solved! I added and exclusion in the dependency. Thank you, again!!

<dependency>
<groupId>com.atlassian.templaterenderer</groupId>
<artifactId>atlassian-template-renderer-api</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</exclusion>
</exclusions>
</dependency>
Alexey Matveev
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.
July 5, 2018

I am glad your question is solved!

Jorge Jerez February 25, 2019

I have the same problem, but version 2.1.0 is not working for me.

I'm using the same code and still not working, I use Jira 7.12

0 votes
jacob delddd July 4, 2018

i changed the version to 2.1.0, did "atlas-mvn idea:idea" in the console. It didn't seem to give an error on the POM anymore, but i still have "cannot resolve templaterenderer".

import com.atlassian.templaterenderer.TemplateRenderer;
Ignacio Sebriano August 31, 2018

I have the same issue here. 

POOJA DHOTRE November 7, 2022

I have same issue. How you solved it?

Suggest an answer

Log in or Sign up to answer