Help us understand the problem. What is going on with this article?

Gradleで実行可能なjarファイルを作成する

More than 1 year has passed since last update.

前提条件

  • intelliJ
  • java8

手順

intelliJで、Gradleプロジェクトを作成する

スクリーンショット 2018-02-18 18.59.58.png

簡単なJavaプログラムを作成して、Gradleの設定ファイルを編集する

src/main/java/HelloWorld.java

public class HelloWorld {
    public static void main(String... args) {
        System.out.println("HEllo World");
    }
}

build.gradle(一部抜粋)

group 'helloworld'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

(中略)

jar {
    manifest {
        attributes 'Main-Class': 'HelloWorld'
    }
}

実際にjarファイルを作成する

以下のgradleコマンドを実行すれば、プロジェクトのbuildディレクトリ配下にjarファイルが作成される

$ gradle build
Starting a Gradle Daemon (subsequent builds will be faster)
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build

BUILD SUCCESSFUL

Total time: 7.82 secs

スクリーンショット 2018-02-18 19.02.42.png

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした