2014-10-31 113 views
-2

我想向Eclipse添加gradle項目,但是這個錯誤已經發生了。沒有這樣的屬性:類的nexusUsername:org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer

FAILURE: Build failed with an exception. 

* Where: 
Script '/Users/user/Downloads/AndroidSlidingUpPanel-master/maven_push.gradle' line: 22 

* What went wrong: 
A problem occurred configuring project ':demo'. 
> A problem occurred configuring project ':library'. 
> No such property: nexusUsername for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer 

和的build.gradle

// Top-level build file where you can add configuration options common to all sub-  projects/modules. 
buildscript { 
    repositories { 
    mavenCentral() 
    } 

dependencies { 
    classpath 'com.android.tools.build:gradle:0.12.+' 
} 
} 

def isReleaseBuild() { 
return version.contains("SNAPSHOT") == false 
} 

allprojects { 
version = VERSION_NAME 
group = GROUP 

    repositories { 
    mavenCentral() 
    } 
} 

如果有人有任何想法解決這個問題,我將不勝感激。

回答

0

如錯誤信息所示,maven_push.gradle(第22行)是指名爲nexusUsername的屬性,但未定義。機會是假設您的~/.gradle/gradle.properties中定義了這樣一個屬性。

1

如果你想構建可能的,即使有人還沒有添加nexusUsername,如果你有一個適當的默認值,可以使用

if (!hasProperty('nexusUsername')) { 
    ext.nexusUsername = '' 
} 

到您的構建腳本。

3

評論線21 maven_push.gradle的23似乎解決了問題

repository(url: sonatypeRepositoryUrl) { 
    authentication(userName: nexusUsername, password: nexusPassword) 
} 

編碼快樂:)

0

創建一個文件〜/ .gradle /用以下內容gradle.properties:

nexusUsername= 
nexusPassword= 

希望它能解決您的問題。

相關問題