Not able to run Bamboo spec written in Kotlin?
Asked by Anders Persson:

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 */ }
}
```


Answers:
author: Alexey Chystoprudov
body: Bamboo is looking for public static main(String\[\]) method of class with @BambooSpecs annotation.

Does your Kotlin class have this method?

comments: author: Anders Persson
body: 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?


author: Alexey Chystoprudov
body: 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


author: Anders Persson
body: Pushed it to github: <https://github.com/anderserikpersson/bamboo-specs-kotlin>

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


author: Alexey Chystoprudov
body: 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


author: Alexey Chystoprudov
body: Source code for mojo is here - <https://bitbucket.org/atlassian/bamboo-specs/src/master/bamboo-specs-runner/>


author: Anders Persson
body: Ok, thanks.


author: Arash Afshar
body: What is the current status after two years? According to the official documentation (see [here](https://confluence.atlassian.com/bamboo0609/bamboo-specs)) 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](/t5/user/viewprofilepage/user-id/3699216) 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] ------------------------------------------------------------------------
```


author: Anders Persson
body: No sorry. Never solved the problem.


Tags: kotlin

spec