Gitlab CI:在Java项目上配置YAML文件

发布于 2025-02-05 12:34:14 字数 805 浏览 1 评论 0原文

我有代表我整个项目的myjava.java。过去,我曾经在Eclipse中执行myjava.java并运行良好,但是现在我想使该过程更加自动化,并使用Gi​​tLab 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彼岸花ソ最美的依靠 2025-02-12 12:34:14

为了使用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文