2016-01-29 56 views
16

當我嘗試將生成的jar安裝到本地Maven資源庫中時,我遇到了一個問題。消息錯誤只顯示我的「任務‘發佈’找不到」使用Gradle向Maven Local發佈Java工件

我使用這個搖籃腳本:

buildscript { 
    ext { 
     springBootVersion = '1.3.2.RELEASE' 
    } 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
    } 
} 

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'idea' 
apply plugin: 'spring-boot' 
apply plugin: 'maven-publish' 

jar { 
    baseName = 'mongofoundry' 
    version = '1.0.0' 
} 
sourceCompatibility = 1.7 
targetCompatibility = 1.7 


repositories { 
    mavenCentral() 
} 


dependencies { 
    compile('org.springframework.boot:spring-boot-starter-web') 
    compile('org.springframework.boot:spring-boot-starter-data-mongodb') 
    testCompile('org.springframework.boot:spring-boot-starter-test') 
} 

publishing { 
    publications { 
     mavenJava(MavenPublication) { 
      from components.java 
     } 
    } 
} 


eclipse { 
    classpath { 
     containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') 
     containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7' 
    } 
} 

task wrapper(type: Wrapper) { 
    gradleVersion = '2.9' 
} 

你有一些想法,爲什麼我讀錯誤訊息? 謝謝。

修訂

執行該命令,@RaGe提到,解決了這個問題:

gradle publishToMavenLocal. 
+4

嘗試'gradle這個publishToMavenLocal ' – RaGe

+0

在早期的'gradle install'工作得很好... – AdamSkywalker

+1

@AdamSkywalker that w ith現在已棄用的'maven'插件。 'maven-publish'改變了一些東西。 – RaGe

回答

25

正確的任務發佈文物本地Maven是

gradle publishToMavenLocal 
相關問題