The procedure I did when I prepared the environment of gradle + Java with VS Code (Windows 10)

I usually use JavaScript, so please let me know if there are any mistakes. Just in case, I will install the tools etc.!

(1) VSCode / gradle / Java installation

This time I will use chocolatey. Click here to install chocolatey (https://chocolatey.org/install#install-with-cmdexe)

choco install vscode -y
choco install gradle -y
choco install openjdk -y

(2) Create gradle project

First, create an appropriate folder and open it with VS Code.

mkdir sample-project
cd sample-project
code . #Open the current directory with vscode

From here it's OK to do it in the vscode terminal

gradle init 
#Option selection
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: Swift
Enter selection (default: Java) [1..5] 3 

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

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

Project name (default: sample-project):
Source package (default: sample.project):

(3) Auto-completion

--Install an extension called Java Extension Pack in VSCode. (Don't forget to restart VS Code)

--Edit build.gradle

build.gradle


plugins {
    id 'java'
    id 'application'
    id 'eclipse' //Add this. To output the classpath for auto-completion.
}

repositories {
    jcenter()
}

dependencies {
    implementation 'com.google.guava:guava:29.0-jre'
    testImplementation 'junit:junit:4.12'
}

mainClassName = 'sample.project.App'

//Add below from here

//Measures against garbled characters
tasks.withType(JavaCompile) {
	options.encoding = "UTF-8"
}

//Have a single executable jar containing dependent libraries created.
jar {
    manifest { attributes 'Main-Class': mainClassName }
    from configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}

--Output classpath

Be sure to run it after changing the dependencies.

gradle eclipse

You should now be able to do auto-completion.

(4) Code formatter (code shaping)

It's already in the Java Extension Pack, so you can do it with Shift + Alt + F.

If you want to make detailed settings, press F1 and enter ʻOpen Java formatter settingsto enter. After that, you will be asked to enter the path of the configuration file, but since it is not there, enter as it is. At the bottom right, you will see something like "'eclipse-formatter.xml' does not exist. Do you want to create it?", So pressYes`.

And now that eclipse-formatter.xml is created, let's set it as you like!

I am changing the following so that the line break code in the method chain etc. is not made into one line at the time of automatic formatting

eclipse-formatter.xml


<!--Change true to false-->
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>

Restart VS Code after setting

Recommended Posts

The procedure I did when I prepared the environment of gradle + Java with VS Code (Windows 10)
Build ruby debug environment with VS Code of Windows 10
Prepare Java development environment with VS Code
Using Gradle with VS Code, build Java → run
Create Spring Boot environment with Windows + VS Code
Build a Java development environment with VS Code
Build Java development environment with VS Code on Mac
Build VS Code + WSL + Java + Gradle environment from scratch
[Mac] VS Code development environment construction (Java, Gradle, Node.js)
Build Java development environment with WSL2 Docker VS Code
How to build Java development environment with VS Code
[Environment construction] Build a Java development environment with VS Code!
Java web application development environment construction with VS Code (struts2)
What I did when I stumbled on IntelliJ gradle 2.2 → 2.6 environment migration
Specify the character code of the source when building with Maven
Java Spring environment in vs Code
I tried to build the environment of PlantUML Server with Docker
Until you run Hello World of JavaFX with VS Code + Gradle
What I did when the DB did not start with docker-compose up
Java build with mac vs code
Building a haskell environment with Docker + VS Code on Windows 10 Home
The point of addiction when performing basic authentication with Java URLConnection
(Fixed) An error occurs when using Java 8 with the latest version (0.65.0) of Language Support for Java (TM) by Red Hat of VS Code.
[Be careful about changing the version of Xdebug! ] Create a development environment with Xdebug3 + docker + VS Code
Java development environment (Mac, VS Code)
When I tried to build an environment of PHP7.4 + Apache + MySQL with Docker, I got stuck [Windows & Mac]
A record of setting up a Java development environment with Visual Studio Code
Problems I was addicted to when building the digdag environment with docker
I was stuck with the handling of the time zone when formatting with SimpleDateFormat
Introduction to Java development environment & Spring Boot application created with VS Code
[day: 5] I summarized the basics of Java
[Code] Forcibly breaks through the C problem "* 3 or / 2" of [AtCoder Problem-ABC100] with Java [Code]
Make SpringBoot1.5 + Gradle4.4 + Java8 + Docker environment compatible with Java11
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Static code analysis with Checkstyle in Java + Gradle
[Java] Explanation of Strategy pattern (with sample code)
Calculate the similarity score of strings with JAVA
What I did when I converted java to Kotlin
Prepare the environment of CentOS 8 with Sakura VPS
I touched on the new features of Java 15
Try debugging a Java program with VS Code
Profile-derived automation of Code Artifact authentication with Gradle
I checked the number of taxis with Ruby
Try the free version of Progate [Java I]
What I was addicted to when developing a Spring Boot application with VS Code
Create a Java (Gradle) project with VS Code and develop it on a Docker container
Summary of how to use the proxy set in IE when connecting with Java
I can't input Japanese with VS code (Visual Studio Code) of Ubuntu 18.04.5! ?? If you want to download VS Code to Ubuntu, go to the official website! !!
CI the architecture of Java / Kotlin applications with ArchUnit
Monitor the internal state of Java programs with Kubernetes
Why can I develop Java with Visual Studio Code?
Check the behavior of Java Intrinsic Locks with bpftrace
[Java] Get the file in the jar regardless of the environment
[Java] Environment construction procedure for developing struts 1.3 with Eclipse
[Java] When writing the source ... A memorandum of understanding ①
I summarized the types and basics of Java exceptions
Prepare the environment for java11 and javaFx with Ubuntu 18.4
Build Java program development environment with Visual Studio Code
Differences in code when using the length system in Java
Beginners create Spring Tools Suite environment with VS Code
The story of making dto, dao-like with java, sqlite