Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Not able to run Bamboo spec written in Kotlin?

Anders Persson January 10, 2020

Managed to write some plan specs in Java and everything worked fine. Tried to do the same with Kotlin but the bamboo-specs-runner isn't able to detect the annotations? Something i'm missing?

 

@BambooSpec
class SpitfireServiceDomainPlanSpec : AbstractPlanSpec() {
public override fun createPlan(): Plan {
 
@com.atlassian.bamboo.specs.api.BambooSpec public final class SpitfireServiceDomainPlanSpec public constructor() : se.lantmateriet.teamtroll.plans.AbstractPlanSpec {
public companion object {
@kotlin.jvm.JvmStatic public final fun main(args: kotlin.Array<kotlin.String>): kotlin.Unit { /* compiled code */ }
}

private final fun buildTasks(): kotlin.Array<com.atlassian.bamboo.specs.api.builders.task.Task<*, *>> { /* compiled code */ }

public open fun createPlan(): com.atlassian.bamboo.specs.api.builders.plan.Plan { /* compiled code */ }
}

1 answer

1 accepted

0 votes
Answer accepted
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 13, 2020

Bamboo is looking for public static main(String[]) method of class with @BambooSpecs annotation.

Does your Kotlin class have this method?

Anders Persson January 15, 2020

New to Kotlin but i think:

public companion object {
@kotlin.jvm.JvmStatic public final fun main(args: kotlin.Array<kotlin.String>): kotlin.Unit { /* compiled code */ }
}

in the *.class should be the same? But maybe i need to do something special with Kotlin?

Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 15, 2020

I'm new to Kotlin as well. If you can share source code/jar file with your code I can check how maven plugin which scan it works

Anders Persson January 15, 2020

Pushed it to github: https://github.com/anderserikpersson/bamboo-specs-kotlin

Removed some sensitive information. Let me know if something is missing.

Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 20, 2020

My debug session confirmed that problem is related to luck of .class files at target folder. Maven mojo which processes Bamboo Specs expects them, but they're not generated by Maven Kotlin plugin

Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 20, 2020
Anders Persson January 20, 2020

Ok, thanks.

Arash Afshar March 11, 2022

What is the current status after two years? According to the official documentation (see here) it should be possible to write "Bamboo-Specs" with Maven and Kotlin. But somehow my "PlanSpec.kt" class with the annotation "@BambooSpec" is not discovered in Bamboo.

Is there an example somewhere? @Anders Persson could you solve the problem?

Thanks for any advice.

 


Logs of Specs status:

 

Content of pom.xml used:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><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">
    <!--Edit template at BAMBOO_INSTALL/atlassian-bamboo/WEB-INF/classes/bamboo-specs-pom.xml-->
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.atlassian.bamboo</groupId>
        <artifactId>bamboo-specs-parent</artifactId>
        <version>6.9.2</version>
        <relativePath/>
    </parent>

    <artifactId>bamboo-specs-generator</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>
    <dependencies>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>bamboo-specs-api</artifactId>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>bamboo-specs</artifactId>
    </dependency>

    <!-- Test dependencies -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib-jdk8</artifactId>
      <version>1.6.10</version>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-test-junit</artifactId>
      <version>1.6.10</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArgs>
                        <compilerArg>-proc:none</compilerArg>
                    </compilerArgs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building bamboo-specs-generator 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> bamboo-specs-runner:6.9.2:run (default-cli) > package @ bamboo-specs-generator >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:copy-resources (copy-license) @ bamboo-specs-generator ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ bamboo-specs-generator ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/atlassian/bamboo/xml-data/build-dir/serverSide/REPOSITORY_STORED_SPECS/repository-411402269/checkout/bamboo-specs/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ bamboo-specs-generator ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0-M1:enforce (enforce-build-environment) @ bamboo-specs-generator ---
[INFO] Skipping Rule Enforcement.
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0-M1:enforce (ban-milestones-and-release-candidates) @ bamboo-specs-generator ---
[INFO] Skipping Rule Enforcement.
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ bamboo-specs-generator ---
[INFO] Not copying test resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ bamboo-specs-generator ---
[INFO] Not compiling test sources
[INFO] 
[INFO] --- maven-surefire-plugin:2.20:test (default-test) @ bamboo-specs-generator ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ bamboo-specs-generator ---
[INFO] Building jar: /var/atlassian/bamboo/xml-data/build-dir/serverSide/REPOSITORY_STORED_SPECS/repository-411402269/checkout/bamboo-specs/target/bamboo-specs-generator-1.0.0.jar
[INFO] 
[INFO] <<< bamboo-specs-runner:6.9.2:run (default-cli) < package @ bamboo-specs-generator <<<
[INFO] 
[INFO] 
[INFO] --- bamboo-specs-runner:6.9.2:run (default-cli) @ bamboo-specs-generator ---
[INFO] Scanning /var/atlassian/bamboo/xml-data/build-dir/serverSide/REPOSITORY_STORED_SPECS/repository-411402269/checkout/bamboo-specs/target/classes for classes annotated with Bamboo plan annotation.
[INFO] Updating ownership of files in /var/atlassian/bamboo/xml-data/build-dir/serverSide/REPOSITORY_STORED_SPECS/repository-411402269/internal-yamls to bamboo
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.424 s
[INFO] Finished at: 2022-03-12T00:07:08+01:00
[INFO] Final Memory: 16M/215M
[INFO] ------------------------------------------------------------------------

 

Anders Persson March 12, 2022

No sorry. Never solved the problem.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events