Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab-ci for java project

I trying to config gitlab-ci file for java project without Maven, Gradle, etc. This is my file:

image: java:latest

stages:
    - build

build:
    stage: build
    script: 
        - '"C:\Program Files\Java\jdk1.8.0_181\bin\javac" StockServer.java'
    artifacts:
        paths:
         - StockServer.*

But my runner install on remote computer, so it can not find StockServer.java (in example HelloWorld.java was in the same directory). How should I set path to file at runners directory? And will it be a compilation of all project (StockServer contains main())? Or just this class?

like image 852
Никита Дрыгин Avatar asked Jan 21 '26 18:01

Никита Дрыгин


1 Answers

My answer will not be quite on the question posed, but I will share my solution - I added gradle to my project, and with it, such .gitlab-ci.yml:

image: java: 8-jdk

stages:
  - build

build:
  stage: build
  script:
    - ./gradlew assemble
  artifacts:
    paths:
      - main_project / build / libs / *. jar

I created jar file assembly on gitlab. It seems to me that this option is better, because I was told that assembling the project "by hand" is not comme il faut.

like image 89
Никита Дрыгин Avatar answered Jan 24 '26 08:01

Никита Дрыгин



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!