Custom datasource into pom plugin project V 8.2.0

Matteo Pilone October 23, 2020

Hello, 

I'm trying to run jira locally with a different datasource, but when I run atlas-run I'm facing this issue:


Failed to execute goal com.atlassian.maven.plugins:jira-maven-plugin:8.2.0:prepare-database (default-prepare-database) on project myPlugin: Product library artifact is empty, please provide library for database: POSTGRES -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.atlassian.maven.plugins:jira-maven-plugin:8.2.0:prepare-database (default-prepare-database) on project myPlugin: Product library artifact is empty, please provide library for database: POSTGRES
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: org.apache.maven.plugin.MojoExecutionException: Product library artifact is empty, please provide library for database: POSTGRES
at com.atlassian.maven.plugins.amps.PrepareDatabaseMojo.getJdbcDriverArtifacts (PrepareDatabaseMojo.java:117)
at com.atlassian.maven.plugins.amps.PrepareDatabaseMojo.prepareDatabase (PrepareDatabaseMojo.java:103)
at com.atlassian.maven.plugins.amps.PrepareDatabaseMojo.doExecute (PrepareDatabaseMojo.java:68)
at com.atlassian.maven.plugins.amps.AbstractProductHandlerMojo.execute (AbstractProductHandlerMojo.java:760)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)


Below my pom configuration:

<?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.tutorial</groupId>
<artifactId>myPlugin</artifactId>
<version>1.0.0-SNAPSHOT</version>

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

<name>myPlugin</name>
<description>This is the com.atlassian.tutorial:myPlugin 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>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>

<!-- 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>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.18</version>
<scope>runtime</scope>
</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>jira-maven-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<instanceId>jira</instanceId>
<products>
<product>
<id>jira</id>
<instanceId>jira</instanceId>
<version>${jira.version}</version>
<dataPath>src/main/resources/empty-home</dataPath>
<server>localhost</server>
<httpPort>9296</httpPort>
<contextPath>/jira</contextPath>
<dataSources>
<dataSource>
<jndi>jdbc/DefaultDS</jndi>
<url>jdbc:postgresql://localhost:5432/jiradb</url>
<username>postgres</username>
<password>postgres</password>
<driver>org.postgresql.Driver</driver>
<defaultDatabase>jiradb</defaultDatabase>
<libArtifacts>
<libArtifact>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.18</version>
<type>jar</type>
</libArtifact>
</libArtifacts>
</dataSource>
</dataSources>
</product>
</products>
<!-- 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>-->

<!-- 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.atlassian.tutorial.myPlugin.api,
</Export-Package>

<!-- Add package import here -->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
*;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>
<includeExclude>-com.atlassian.plugin.spring.scanner.annotation.*</includeExclude>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<jira.version>8.2.0</jira.version>
<amps.version>8.2.0</amps.version>
<plugin.testrunner.version>2.0.1</plugin.testrunner.version>
<atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
<!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
<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>
<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>



It looks like that amps.maven.plugin doesn't recognize the product. 
Here the snippet code where the Execption is launched:

package => amps-maven-plugin
class => com.atlassian.maven.plugins.amps.PrepareDatabaseMojo.class

snippet:

@Override
protected void doExecute() throws MojoExecutionException, MojoFailureException {
if (this.testsSkip || this.skipTests) {
this.getLog().info((CharSequence)"Pre integration tests skipped");
return;
}
final MavenGoals goals = this.getMavenGoals();
final List<ProductExecution> productExecutions = this.getProductExecutions();
if (productExecutions != null) {
for (final ProductExecution productExecution : productExecutions) {
if ("jira".equals(productExecution.getProduct().getId())) {
final List<DataSource> dataSources = productExecution.getProduct().getDataSources();
switch (dataSources.size()) {
case 1: {
final DataSource dataSource = dataSources.get(0);
final Object o;
final Object o2;
final JiraDatabaseType databaseType = JiraDatabaseType.getDatabaseType(dataSource).orElseThrow(() -> {
new MojoExecutionException("Could not detect database type for dataSource: " + o2);
return o;
});
final List<ProductArtifact> libArtifacts = productExecution.getProduct().getLibArtifacts();
if (libArtifacts == null || libArtifacts.isEmpty()) {
throw new MojoExecutionException("Product library artifact is empty, please provide library for database: " + databaseType);
}
for (final ProductArtifact productArtifact : libArtifacts) {
dataSource.getLibArtifacts().add(new LibArtifact(productArtifact.getGroupId(), productArtifact.getArtifactId(), productArtifact.getVersion()));
}
this.populateDatasourceParameter(dataSource);
goals.runPreIntegrationTest(dataSource);
continue;
}


Can you please help me to figure out which configuration I am missing ?

Thank in Advance

0 answers

Suggest an answer

Log in or Sign up to answer