Gitlab CI:在Java项目上配置YAML文件
我有代表我整个项目的myjava.java。过去,我曾经在Eclipse中执行myjava.java并运行良好,但是现在我想使该过程更加自动化,并使用GitLab Runner Pipeline执行它。
我的yaml文件很简单,只需阅读myjava.java并执行它即可。
build:
stage: build
only:
- myBranch
tags:
- MyBuilder
image: openjdk:8-jdk
script: javac MyPath/MyJava.java
Myjava具有连接到其他文件的代码和依赖关系,
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;
但是每当我执行文件时,都会显示每个导入/软件包的错误,例如:
error: package com.google.inject does not exist - import com.google.inject.Inject;
有提示吗?
执行myjava.javewill生成一个包含我想要的数据的JAR文件的结果。我只是提到了这一点,以防您有另一种方式。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使用CI/CD管道构建Java工件(JAR或WAR),您必须配置项目以使用依赖关系管理器,例如Maven,Gradle或Ant。配置项目后,您将能够在YML文件上定义构建脚本,以将所有必要的依赖项编译为Java伪像。
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.