Create a jar file that can be executed in Gradle

Prerequisites

procedure

Create a Gradle project in intelliJ

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

Create a simple Java program and edit the Gradle config file

src/main/java/HelloWorld.java

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

build.gradle (partial excerpt)

group 'helloworld'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8

(Omitted)

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

Actually create a jar file

If you execute the following gradle command, a jar file will be created under the build directory of the project.

$ 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

Recommended Posts

Create a jar file that can be executed in Gradle
Write a class that can be ordered in Java
Log out a CSV file that can be read in Excel using logback
Create a page control that can be used with RecyclerView
How to create a new Gradle + Java + Jar project in Intellij 2016.03
Add a time stamp to the JAR file name in Gradle
Create a jar file with the command
A bat file that uses Java in windows
[OpenJDK11 & JavaFX13] Build a javaFX app with IntelliJ + gradle and create a package that can be distributed with a lightweight JRE
[Android] I want to create a ViewPager that can be used for tutorials
Create a Jar file with two lines of command
Convenient shortcut keys that can be used in Eclipse
Create a Java Servlet and JSP WAR file to deploy to Apache Tomcat 9 in Gradle
List of devices that can be previewed in Swift UI
Programming can be a god.
What is a jar file?
[Java] Create a temporary file
Create a method that can retrieve characters from any location
Introduction to Rakefile that can be done in about 10 minutes
Find a Switch statement that can be converted to a Switch expression
Java (super beginner edition) that can be understood in 180 seconds
Set up Gradle multi-project in IntelliJ to build JAR file
I want to create a Parquet file even in Ruby
Generate a single executable jar with dependent libraries in Gradle 4.9
Object-oriented design that can be used when you want to return a response in form format
How to make a key pair of ecdsa in a format that can be read by Java
[Swift5] How to create a .gitignore file and the code that should be written by default
Reference memo / In-memory LDAP server that can be embedded in Java
How to create a jar file or war file using the jar command
Create a static file that expands variables using the ERB class
Summary of ORM "uroboroSQL" that can be used in enterprise Java
File form status check sheet that can be deleted with thumbnails
I made a question that can be used for a technical interview
SwiftUI View that can be used in combination with other frameworks
Mecab installation that can be done almost by typing a command
Create a database in a production environment
Create a new app in Rails
Make multi-project executable JAR in Gradle
Create a Servlet program in Eclipse
Include image resources in jar file
[Java 8] Until converting standard input that can be used in coding tests into a list or array
Command line that can create a directory structure for building a Laravel environment with Docker in one shot
How to override in a model unit test so that Faker can be used to generate random values
[Spring Boot] List of validation rules that can be used in the property file for error messages
Java file input / output processing that can be used through historical background
To create a Zip file while grouping database search results in Java
[Java] Create a jar file with both compressed and uncompressed with the jar command
[Rails] "pry-rails" that can be used when saving with the create method
How to create a server executable JAR and WAR with Spring gradle
Sample program that returns the hash value of a file in Java
[Android Studio] Description that can be continuously input in SQLite Database [Java]
How to add jar file in ScalaIDE
Create a TODO app in Java 7 Create Header
Object-oriented that can be understood by fairies
Configure a multi-project with subdirectories in Gradle
Create a List that holds multiple classes
Technology excerpt that can be used for creating EC sites in Java training
[Windows] gem install sqlite3 cannot be done ~ Cannot create temporary file in C: \ version ~
Create a Windows desktop application in Ruby and distribute an executable file (.exe)!
I made a THETA API client that can be used for plug-in development
Let's create a versatile file storage (?) Operation library by abstracting file storage / acquisition in Java