NPE when publishing war to directory

Hi

I’m playing around with gradle 3.3 and have some issues publishing a war file to a directory.

Using ‘gradlew uploadArchives’ results in a NullPointerException.

  • What went wrong:
    Execution failed for task ‘:uploadArchives’.

Could not publish configuration 'archives’
java.lang.NullPointerException (no error message)

Stacktrace

Caused by: org.gradle.api.artifacts.PublishException: Could not publish configuration 'archives'
        at org.gradle.api.tasks.Upload.upload(Upload.java:66)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:632)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:615)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
        ... 70 more
Caused by: java.lang.NullPointerException
        at org.gradle.util.GFileUtils.mkdirs(GFileUtils.java:296)
        at org.gradle.internal.resource.transport.file.FileResourceConnector.put(FileResourceConnector.java:59)
        at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.put(ExternalResourceResolver.java:328)
        at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.publish(ExternalResourceResolver.java:323)
        at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.publish(ExternalResourceResolver.java:308)
        at org.gradle.api.internal.artifacts.ivyservice.publisher.DefaultIvyDependencyPublisher.publish(DefaultIvyDependencyPublisher.java:45)
        at org.gradle.api.internal.artifacts.ivyservice.publisher.IvyBackedArtifactPublisher.publish(IvyBackedArtifactPublisher.java:78)
        at org.gradle.api.internal.artifacts.ivyservice.IvyContextualArtifactPublisher$1.execute(IvyContextualArtifactPublisher.java:43)
        at org.gradle.api.internal.artifacts.ivyservice.IvyContextualArtifactPublisher$1.execute(IvyContextualArtifactPublisher.java:40)
        at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
        at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:61)
        at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:39)
        at org.gradle.api.internal.artifacts.ivyservice.IvyContextualArtifactPublisher.publish(IvyContextualArtifactPublisher.java:40)
        at org.gradle.api.tasks.Upload.upload(Upload.java:64)
        ... 78 more

My build.gradle file.

apply plugin: 'java’
apply plugin: 'war’
apply plugin: ‘eclipse-wtp’

task wrapper(type: Wrapper) {
description = 'Generates gradlew and gradlew.bat bootstrap scripts’
gradleVersion = ‘3.3’
}

sourceCompatibility = JavaVersion.VERSION_1_7

repositories {
mavenCentral()
}

dependencies {
compile ‘log4j:log4j:1.2.17’

providedCompile ‘javax:javaee-api:7.0’
}

war {
manifest {
attributes ‘Implementation-Title’: rootProject.name ,
‘Implementation-Version’: version,
‘Built-Date’: new Date()
}
}

uploadArchives {
repositories {
flatDir {dirs “file://c/temp/test/” }
}
}

Anybody an idea whats wrong with my gradle setup?

thanks
cyrill

I’m still trying to figure out why this NullPointerException occurs.

Tried some different approach by adding an own copy task.

task deployLocal(type: Copy) {
configurations.archives.each( println(it) )

from configurations.archives.allArtifacts*.file 
into("file://c/temp/test/") 

}

Unfortunately same error occurs. Anyone an idea?

gradlew jar deployLocal

thx & regards
Cyrill