既存Webプロジェクトをgradleプロジェクトに変更
プロジェクト設定
プロジェクトを右クリック → 構成 → Gradleネーチャーの追加
build.gradle
プロジェクト直下に、build.gradleファイルを作成する
↓↓↓↓
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
apply plugin: 'java' apply plugin: 'war' def defaultEncoding = 'UTF-8' def warFileName = Sample.war' version = 1.0 sourceCompatibility = 1.7 targetCompatibility = 1.7 repositories { jcenter() } dependencies { compile fileTree(dir: "WebContent/WEB-INF/lib", include: '*.jar') providedCompile 'org.apache.tomcat:tomcat-servlet-api:7.0.88' providedCompile 'org.apache.tomcat:tomcat-jsp-api:7.0.88' providedCompile 'org.apache.tomcat:tomcat-catalina:7.0.88' } project.webAppDirName = 'WebContent' sourceSets { main { java { srcDir 'src' } resources { srcDir 'resources' } } } compileJava { options.encoding = defaultEncoding } war { archiveName warFileName exclude 'WEB-INF/lib/**' exclude 'WEB-INF/classes/**' } |
プロジェクトを右クリック → Gradle → Gradleプロジェクトのリフレッシュ
以上です。