2016-11-11 76 views
0

我有一個java庫,我想上傳到jfrog artifactory。但無論我做什麼,我得到一個空指針異常:ArtifactoryPublish失敗,空指針異常

Execution failed for task :util-lib-java:artifactoryPublish. java.lang.NullPointerException (no error message)

,今年的工作完美的罰款在10月3日,並未能在第10位。然後我們引用了版本:classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.*"以及我可以看到jfrog在這些日期之間將它們的庫從4.4.5更新到了4.47。但現在,當我嘗試使用各種版本時,我只能得到上面指定的錯誤。

我的build.gradle樣子:

buildscript { 
repositories { 
    jcenter() 
    maven { 
     url "${artifactory_contextUrl}/plugins-release" 
     credentials { 
      username = "${artifactory_user}" 
      password = "${artifactory_password}" 
     } 
    } 

} 
dependencies { 
    //Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory 
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.2" 
} 
} 

apply plugin: 'java' 
apply plugin: 'com.jfrog.artifactory' 
apply plugin: 'maven-publish' 


repositories 
    { 
     mavenCentral() 
     maven { 
      url "${artifactory_contextUrl}/libs-release-local" 
     } 
     maven { 
      url "${artifactory_contextUrl}/libs-snapshot-local" 
     } 
    } 

// Android project is also using this library, so java version cannot be 1.8 
sourceCompatibility = 1.7 
targetCompatibility = 1.7 

publishing { 
publications { 
    mavenJava(MavenPublication) { 

     // Set the base name of the artifacts 
     artifactId 'util-lib-java' 
     groupId group 
     version version 

     from components.java 
    } 
} 
} 


artifactory { 
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver 
publish { 
    repository { 
     if (project.version.endsWith('-SNAPSHOT')) { 
      repoKey = 'libs-snapshot-local' 
     } else { 
      repoKey = 'libs-release-local' 
     } 
     username = "${artifactory_user}" 
     password = "${artifactory_password}" 
     maven = true 
    } 
    defaults { 
     publications ('mavenJava') 
    } 
} 
} 

和頂級的build.gradle樣子:

buildscript { 
repositories { 
    jcenter() 
} 
dependencies { 
    classpath 'com.android.tools.build:gradle:2.1.3' 
    // NOTE: Do not place your application dependencies here; they belong 
    // in the individual module build.gradle files 
} 
} 

allprojects { 
version = '1.0' 
group = 'com.companyname' 

repositories { 
    jcenter() 
} 
} 

我們使用gradle-2.14.1-bin.zip包裝。從構建

堆棧跟蹤:

* Exception is: 
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':util-lib-java:artifactoryPublish'. 
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) 
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) 
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) 
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66) 
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52) 
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) 
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) 
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) 
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) 
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) 
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) 
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) 
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) 
Caused by: java.lang.NullPointerException 
    at org.jfrog.gradle.plugin.artifactory.task.BuildInfoBaseTask.prepareAndDeploy(BuildInfoBaseTask.java:346) 
    at org.jfrog.gradle.plugin.artifactory.task.BuildInfoBaseTask.collectProjectBuildInfo(BuildInfoBaseTask.java:132) 
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) 
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228) 
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221) 
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210) 
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:621) 
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:604) 
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) 
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) 

缺少什麼我在這裏? This issue不幫我

+0

你有沒有解決這個問題? – lukaville

回答

1

對於發佈你必須在你gradle.propertieslocal.properties刪除此行:

org.gradle.configureondemand=true 
org.gradle.daemon=true 

你也需要在主build.gradle文件中添加這一點。

allprojects { 
    apply plugin: 'com.jfrog.artifactory' 
    ... 
} 

之後,出版應該是工作。

+0

好的,會試試看。 – peuhse