2017-12-14 1 views
1

를 구축하지 않습니다그림자 플러그인이 작동하지 않습니다 - Gradle을 빌드 내가 <code>build.gradle</code> 내용은 다음 한 지방 항아리

group 'com.example' 
version '1.0-SNAPSHOT' 

buildscript { 
    repositories { 
     mavenLocal() 
     mavenCentral() 
     jcenter() 
     maven { url "https://plugins.gradle.org/m2/" } 
    } 
    dependencies { 
     classpath "com.github.jengelman.gradle.plugins:shadow:2.0.1" 
    } 
} 


apply plugin: 'scala' 
apply plugin: "com.github.johnrengelman.shadow" 
sourceCompatibility = java_version 


repositories { 
    mavenCentral() 
} 

dependencies { 
    // my dependencies: 
    compile group: 'org.apache.spark', name: "spark-sql_$scala_major", version: spark_version 
    testCompile group: 'junit', name: 'junit', version: '4.12' 
} 

문제는 gradle build를 실행하는 것은 지방 항아리를 만드는되지 않는 것입니다.

gradle tasks --all을 실행하여 작업 종속성을 보면은 shadowJar 작업이 존재 함을 보여주고 있지만, build 작업에 종속되지 않습니다 :

:tasks 

------------------------------------------------------------ 
All tasks runnable from root project 
------------------------------------------------------------ 

Build tasks 
----------- 
assemble - Assembles the outputs of this project. 
build - Assembles and tests this project. 
buildDependents - Assembles and tests this project and all projects that depend on it. 
buildNeeded - Assembles and tests this project and all projects it depends on. 
classes - Assembles main classes. 
clean - Deletes the build directory. 
jar - Assembles a jar archive containing the main classes. 
testClasses - Assembles test classes. 

Build Setup tasks 
----------------- 
init - Initializes a new Gradle build. 
wrapper - Generates Gradle wrapper files. 

Documentation tasks 
------------------- 
javadoc - Generates Javadoc API documentation for the main source code. 
scaladoc - Generates Scaladoc for the main source code. 

Help tasks 
---------- 
buildEnvironment - Displays all buildscript dependencies declared in root project 'scalaGradleHW'. 
components - Displays the components produced by root project 'scalaGradleHW'. [incubating] 
dependencies - Displays all dependencies declared in root project 'scalaGradleHW'. 
dependencyInsight - Displays the insight into a specific dependency in root project 'scalaGradleHW'. 
dependentComponents - Displays the dependent components of components in root project 'scalaGradleHW'. [incubating] 
help - Displays a help message. 
model - Displays the configuration model of root project 'scalaGradleHW'. [incubating] 
projects - Displays the sub-projects of root project 'scalaGradleHW'. 
properties - Displays the properties of root project 'scalaGradleHW'. 
tasks - Displays the tasks runnable from root project 'scalaGradleHW'. 

Shadow tasks 
------------ 
knows - Do you know who knows? 
shadowJar - Create a combined JAR of project and runtime dependencies 

Verification tasks 
------------------ 
check - Runs all checks. 
test - Runs the unit tests. 

Other tasks 
----------- 
compileJava - Compiles main Java source. 
compileScala - Compiles the main Scala source. 
compileTestJava - Compiles test Java source. 
compileTestScala - Compiles the test Scala source. 
processResources - Processes main resources. 
processTestResources - Processes test resources. 
+0

에 defaultTasks 라인을 단순화 ','build' ->'assemble' ->'shadowDistTar' ->'shadowJar'와 같은 종속성 체인을 발생시키는'Distribution plugin'을 암묵적으로 적용합니다. 'gradle build '를 호출하는이 방법은 내가 예상했던 fatJar를 생성합니다. –

답변

0

The 'build' task in Gradle is commonly mistaken을 프로젝트의 모든 작업을 빌드 작업. '빌드'작업은 실제로 자바 기반의 플러그인을 제공하고 다음과 같은 작업이 포함됩니다 :

대신 'Gradle을 빌드'를 실행
compileJava, processResources, classes, jar, assemble, compileTestJava, processTestResources, testClasses, test, and check 

내가 그 라인을 퍼팅 defaultsTasks

`defaultTasks 'build', 'shadowJar'` 

의 사용을 권장을 build.gradle에서 build와 shadowJar가 둘 다 실행되도록 인수없이 Gradle을 호출 할 수 있습니다.

> gradle 

은 내가 shadowJar 플러그인에 익숙하지 않은,하지만 그것은 shadowJar라는 이름의 작업을 노출하는 경우, build.gradle에서의 DependsOn 라인의 사용은 defaultTasks 라인을 단순화 할 수있다. '프로그램'

project.tasks.shadowJar.dependsOn build 

'는 플러그인을 적용 (https://docs.gradle.org/current/userguide/application_plugin.html) [어플리케이션 플러그인]을

defaultTasks shadowJar 
관련 문제