NPE in artifacts resolution

I create a custom artifact on one project that points to a folder (an exploded war file).
Next I attempt to use it from the other project. This ends with the following error

Fails with Gradle 2.5, and 2.9

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':tests:tests-war-loader-impl:explodedWars'.
	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:64)
	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.gradle.api.internal.artifacts.DefaultResolvedArtifact.hashCode(DefaultResolvedArtifact.java:74)
	at org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.DefaultArtifactSet.getArtifacts(DefaultArtifactSet.java:75)
	at org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.DefaultResolvedArtifactResults.resolveNow(DefaultResolvedArtifactResults.java:58)
	at org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.DefaultResolvedArtifactsBuilder.resolve(DefaultResolvedArtifactsBuilder.java:35)
	at org.gradle.api.internal.artifacts.DefaultResolverResults.getResolvedArtifacts(DefaultResolverResults.java:119)
	at org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolver.resolveArtifacts(DefaultConfigurationResolver.java:103)
	at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyConfigurationResolver.resolveArtifacts(SelfResolvingDependencyConfigurationResolver.java:46)
	at org.gradle.api.internal.artifacts.ivyservice.ShortCircuitEmptyConfigurationResolver.resolveArtifacts(ShortCircuitEmptyConfigurationResolver.java:61)
	at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.resolveArtifacts(ErrorHandlingConfigurationResolver.java:56)
	at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveArtifactsIfRequired(DefaultConfiguration.java:403)
	at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveNow(DefaultConfiguration.java:345)
	at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(DefaultConfiguration.java:335)
	at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)
	at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:661)
	at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:288)
	at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getFiles(Unknown Source)
	at org.gradle.api.internal.file.AbstractFileCollection.iterator(AbstractFileCollection.java:65)
	at build_2zi767grdflywvognc39qyway$_run_closure3$_closure6.doCall(/Users/jonnyzzz/Work/vcs-hosting/tests/tests-war-loader-impl/build.gradle:32)
	at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:554)
	at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:535)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
	... 14 more

Can you share some of your build script?

Sure. I have a module for war like that

configurations {
    root

    exploded2
}

apply plugin: 'war'

def explodedDir = file("$buildDir/exploded")

task explodedWar {
    outputs.dir(explodedDir)

    doLast {
        delete explodedDir
        copy {
            into explodedDir
            with war
        }
    }
}

war.dependsOn explodedWar


//this is how I declared the problem artifact
artifacts {
    exploded2 file: explodedDir, builtBy: explodedWar
}

The usage of it was from another project, e.g.

configurations {
  exploded2
}

dependencies {
  exploded2 project(path: ':package:package-web', configuration: 'exploded2')
}

apply plugin: 'war'


def explodedWarsPath = "$buildDir/apps"

task explodedWars << {
  copy {
    //fails here
    from configurations.exploded2.collect()
    into "$explodedWarsPath/master"
  }
}

compileJava.dependsOn explodedWars

I simplified script, hope it will still reproduce the NPE. Finally I changed it to publish war archive, and it looks working now