0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

とりあえずgradleを触る(mac)

Posted at

ここに書いてあるチュートリアルのメモ書き。
https://docs.gradle.org/current/samples/sample_building_java_applications.html

gradleインストール

brew install gradle

手動インストールは面倒なのでhomebrew利用。

おためしPJ作成

gradle initで選択するもの。

  • Select type of project to generate:
    • 2: application を選択。
  • Select implementation language:
    • 3: Java を選択。
  • それ以外はデフォルト値(エンター押すだけ)でOK
$ mkdir demo
$ cd demo
$ gradle init
Starting a Gradle Daemon (subsequent builds will be faster)

Select type of project to generate:
  1: basic
  2: application
  3: library
  4: Gradle plugin
Enter selection (default: basic) [1..4] 2

Select implementation language:
  1: C++
  2: Groovy
  3: Java
  4: Kotlin
  5: Scala
  6: Swift
Enter selection (default: Java) [1..6] 3

Split functionality across multiple subprojects?:
  1: no - only one application project
  2: yes - application and library projects
Enter selection (default: no - only one application project) [1..2] 

Select build script DSL:
  1: Groovy
  2: Kotlin
Enter selection (default: Groovy) [1..2] 

Select test framework:
  1: JUnit 4
  2: TestNG
  3: Spock
  4: JUnit Jupiter
Enter selection (default: JUnit 4) [1..4] 

Project name (default: demo): 
Source package (default: demo): 

> Task :init
Get more help with your project: https://docs.gradle.org/7.0/samples/sample_building_java_applications.html

BUILD SUCCESSFUL in 42s
2 actionable tasks: 2 executed
  • demoディレクトリの下にPJができあがっているはずなので確認する。

おためしHelloWorld

$ ./gradlew run
Downloading https://services.gradle.org/distributions/gradle-7.0-bin.zip
..........10%...........20%...........30%..........40%...........50%...........60%...........70%..........80%...........90%...........100%
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

> Task :app:run
Hello World!

おためしビルド

$ ./gradlew build

BUILD SUCCESSFUL in 8s
7 actionable tasks: 6 executed, 1 up-to-date

ビルドすると以下ファイルができあがる。

app/build/distributions/app.tar
app/build/distributions/app.zip
app/build/libs/app.jar
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?