简体   繁体   中英

GitLab CI: configure YAML file on java project

I have the MyJava.Java that represents my whole project. In the past, I used to execute MyJava.Java in eclipse and working well, but now I want to make the process much more automated and execute it using the GitLab runner pipeline.

my YAML file is very simple just read the MyJava.Java and execute it.

build:
  stage: build
  only:
      - myBranch
  tags:
    - MyBuilder
  image: openjdk:8-jdk
  script: javac MyPath/MyJava.java

MyJava has a code and dependency that connected to other files such as this

package myfolder.generator;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Provider;
import java.util.List;
import org.eclipse.emf.common.util.URI;

But whenever I execute the file it shows an error of every import/package such as:

error: package com.google.inject does not exist - import com.google.inject.Inject;

Any hint?

The result of executing the MyJava.Javewill generates a jar file that contains the data that I want. I just mentioned this in case you have another way.

In order to build a java artifact (jar or war) using a CI/CD pipeline you must configure your project to use a dependency manager such as Maven, Gradle or Ant. After you configure your project you will be able to define a build script on the YML file to compile all the necessary dependencies into a java artifact.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM