🧑‍💻복습/자바

자바 복습 ! eclipse로 teacher repo import 하기 (gradle 설정)

우동한그릇 2023. 6. 13. 10:43
반응형

* settings 와 build gradle 설정할 때는 폴더 경로에 따른 코드를 수정해주어야한다.

 

1. settings.grdle 설정

/*
 * This file was generated by the Gradle 'init' task.
 *
 * The settings file is used to specify which projects to include in your build.
 *
 * Detailed information about configuring a multi-project build in Gradle can be found
 * in the user manual at https://docs.gradle.org/8.1.1/userguide/multi_project_builds.html
 */

plugins {
    // Apply the foojay-resolver plugin to allow automatic download of JDKs
    id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0'
}

rootProject.name = 'java-lang'
include('app')

 

 

2. build.gradle 설정

 

plugins {
    id 'application'
    id 'eclipse'
}

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1'

    implementation 'com.google.guava:guava:31.1-jre'
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

application {
    mainClass = 'bitcamp.java-lang.App'
}

tasks.named('test') {
    useJUnitPlatform()
}

// 자바 소스를 컴파일 할 때 적용할 옵션
tasks.withType(JavaCompile) {
    // 프로젝트의 소스 파일 인코딩을 gradle에게 알려준다.
    // $javac -encoding UTF-8 ..
    options.encoding = 'UTF-8' 

    // 소스 파일을 작성할 때 사용할 자바 버전
    sourceCompatibility = '17'

    // 자바 클래스를 실행시킬 JVM의 최소 버전
    targetCompatibility = '17'
}

// eclipse 프로젝트 이름을 설정하기
eclipse {
    project {
        name = "java-lang"
    }
    jdt {
      sourceCompatibility = 17
      targetCompatibility = 17
      javaRuntimeName = "JavaSE-17"
    }
}

 

 

3. 폴더 경로로 이동하여 gradle eclips 실행하여 플러그인 설치

 

 

 

 

4. Eclipse 실행하여 import를 app폴더로 지정 후 실행

 

 

반응형