사랑해 마니마니

gradle java project 만들기 본문

카테고리 없음

gradle java project 만들기

분리불안증후군 2016. 3. 7. 23:05

그래들 설치 확인

$  gradle -v


그래들 task 확인

$ gradle tasks 


project 폴더 생성

$ _project_name_


java project 생성

$ gradle init --type java-library


gradle java 프로젝트 생성결과

$ tree


빌드

$ gradle build

    . unmappable character for encoding MS949 오류 발생시

      > 시스템 환경변수에 

            변수이름(N): GRADLE_OPTS

변수값(V):-Dfile.encoding=UTF-8

을 추가


빌드 결과 확인

$ tree /F


빌드 결과 삭제

$ gradle clean


gradle 테스트

$ gradle test



----------------------------------

build.gradle


apply plugin: 'java'


def defaultEncoding = 'UTF8'


sourceCompatibility = 1.8

targetCompatibility = 1.8


tasks.withType(JavaCompile) {

 options.encoding = defaultEncoding

}


repositories {

    mavenCentral()

}


dependencies {

    testCompile "junit:junit:4.11"

}


#jar 파일명 설정: ${baseName}-${appendix}-${version}-${classifier}.jar

jar {

 baseName = 'example'

 appendix = 'bin'

 version = '0.1'

 classifier = 'jdk18'

}








1. Workspace에 폴더 만들기 (workspace 변경은 File > Switch workspace)


2. gradle init --type java-library


3. build.gradle 편집

  https://github.com/spring-guides/gs-spring-boot/blob/master/complete/build.gradle 참고


4. gradle check


5. gradle initProject < 오류남.. T.T


6. gradle eclipse


7. sts에서 import > Browse > Build Model



<textarea name="code" class="brush:Groovy;">


buildscript {

    repositories {

        jcenter()

    }

    dependencies {

        classpath 'io.spring.gradle:dependency-management-plugin:0.5.4.RELEASE'

    }

}

 

apply plugin: 'java'

apply plugin: 'io.spring.dependency-management'

apply plugin: 'eclipse'

 

dependencyManagement {

    imports {

        mavenBom 'io.spring.platform:platform-bom:2.0.1.RELEASE'

    }

}

 

repositories {

    jcenter()

}


targetCompatibility = 1.8

sourceCompatibility = 1.8


dependencies {

    compile      ('org.springframework.boot:spring-boot-starter-batch')

    compile      ('org.hsqldb:hsqldb')

    testCompile  ('junit:junit')

    compile      ('org.springframework.boot:spring-boot-devtools')

    compile      ('org.springframework.boot:spring-boot-starter-thymeleaf')

    testCompile  ('org.springframework.boot:spring-boot-starter-test')

}





</textarea>



Comments