philgsk
philgsk

Reputation: 57

Integrate Java Lombok in Bitbucket Pipeline

I'm currently creating a Bitbucket Pipeline for CI/CD my Spring Boot application to AWS ECS. I could not figure out how to integrate lombok. Without i get a lot of compilation errors because the annotations are not translated properly.

# This is a sample build configuration for Java (Maven).
# Check our guides at https://confluence.atlassian.com/x/zd-5Mw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: maven:3.5.2-jdk-8

pipelines:
branches:
master:
- step:
    name: Installing
    caches:
      - maven
    script: # Modify the commands below to build your repository.
      - mvn -B verify # -B batch mode makes Maven less verbose
- step:
    name: Build Docker Image
    services:
      - docker
    image: atlassian/default-image:2
    script:
        - echo $(aws ecr get-login --no-include-email --region eu-central-1) > login.sh
        - sh login.sh
        - docker build -f Dockerfile -t $ECR_STAGING_REPO_NAME .
        - docker tag $ECR_STAGING_REPO_NAME:latest $ECR_STAGING_REPO_URI:latest
        - docker push $ECR_STAGING_REPO_URI:latest
- step:
    name: Deploy to Production
    services:
      - docker
    deployment: production
    script:
      - pipe: atlassian/aws-ecs-deploy:1.0.6
        variables:
          AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
          AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
          AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
          CLUSTER_NAME: $ECS_PRODUCTION_CLUSTER_NAME
          SERVICE_NAME: $ECS_PRODUCTION_SERVICE_NAME
          TASK_DEFINITION: 'production_task_definition.json'

Sample Error:

[ERROR] /<path>:[74,74] cannot find symbol
  symbol:   method getDeviceId()
  location: variable gameCredentials of type ...

Upvotes: 0

Views: 738

Answers (2)

TechMaster
TechMaster

Reputation: 261

In you pom.xml file add following dependencies for lombok in a way like:

<dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <scope>provided</scope>
</dependency>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <excludes>
                    <exclude>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                    </exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>
</build>

Upvotes: 0

Fionn O&#39;Connor
Fionn O&#39;Connor

Reputation: 81

Have you added the Lombok plugin to your build section in your pom.xml?

<build>
  <plugins>
    <plugin>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok-maven-plugin</artifactId>
      <version>1.18.10.0</version>
      <executions>
        <execution>
          <phase>generate-sources</phase>
          <goals>
            <goal>delombok</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

http://anthonywhitford.com/lombok.maven/lombok-maven-plugin/usage.html

Upvotes: 2

Related Questions