[GRADLE-734] Neither path nor baseDir may be null or empty string Created: 10/Nov/09  Updated: 04/Jan/13  Resolved: 24/Nov/10

Status: Resolved
Project: Gradle
Affects Version/s: 0.9
Fix Version/s: 0.9-rc-1

Type: Bug
Reporter: Spencer Allain Assignee: Adam Murdoch
Resolution: Fixed Votes: 0

Attachments: Zip Archive nullpath.zip    

 Description   

Running the default task of build, received this error

FAILURE: Build aborted because of an internal error.

  • What went wrong:
    Build aborted because of an unexpected internal error. Please file an issue at: www.gradle.org.
  • Try:
    Run with -d option to get additional debug info.
  • Exception is:
    java.lang.IllegalArgumentException: Neither path nor baseDir may be null or empty string. path='null' basedir='/staging/sallain/parent/component2'
    at org.gradle.api.internal.file.BaseDirConverter.doResolve(BaseDirConverter.java:36) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:35) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:31) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.file.PathResolvingFileCollection.resolveToFilesAndFileCollections(PathResolvingFileCollection.java:138) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.file.PathResolvingFileCollection.addSourceCollections(PathResolvingFileCollection.java:91) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.file.CompositeFileCollection.getSourceCollections(CompositeFileCollection.java:127) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.file.CompositeFileCollection.addDependencies(CompositeFileCollection.java:120) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.file.PathResolvingFileCollection.addDependencies(PathResolvingFileCollection.java:85) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.file.CompositeFileCollection$2.getDependencies(CompositeFileCollection.java:109) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.tasks.DefaultTaskDependency.getDependencies(DefaultTaskDependency.java:52) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.file.CompositeFileCollection$2.getDependencies(CompositeFileCollection.java:110) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.tasks.DefaultTaskDependency.getDependencies(DefaultTaskDependency.java:52) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.DefaultTaskGraphExecuter.fillDag(DefaultTaskGraphExecuter.java:112) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.DefaultTaskGraphExecuter.addTasks(DefaultTaskGraphExecuter.java:66) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.TaskNameResolvingBuildExecuter.select(TaskNameResolvingBuildExecuter.java:46) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.DelegatingBuildExecuter.select(DelegatingBuildExecuter.java:46) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.ProjectDefaultsBuildExecuter.select(ProjectDefaultsBuildExecuter.java:42) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.DelegatingBuildExecuter.select(DelegatingBuildExecuter.java:46) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.DefaultBuildExecuter.select(DefaultBuildExecuter.java:52) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.GradleLauncher.doBuildStages(GradleLauncher.java:185) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.GradleLauncher.doBuild(GradleLauncher.java:128) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.GradleLauncher.run(GradleLauncher.java:98) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.launcher.Main.execute(Main.java:93) [gradle-launcher-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.launcher.Main.main(Main.java:42) [gradle-launcher-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0_12]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [na:1.6.0_12]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [na:1.6.0_12]
    at java.lang.reflect.Method.invoke(Method.java:597) [na:1.6.0_12]
    at org.gradle.launcher.GradleMain.main(GradleMain.java:50) [gradle-launcher-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]

Explicitly running gradle compileJava produces this:

  • Exception is:
    java.lang.NullPointerException: null
    at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository$TaskInfo.<init>(DefaultTaskArtifactStateRepository.java:229) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository.getThisExecution(DefaultTaskArtifactStateRepository.java:91) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository.getStateFor(DefaultTaskArtifactStateRepository.java:48) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.project.ExecutionShortCircuitTaskExecuter.execute(ExecutionShortCircuitTaskExecuter.java:55) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.tasks.SkipTaskExecuter.doExecute(SkipTaskExecuter.java:63) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.tasks.SkipTaskExecuter.execute(SkipTaskExecuter.java:36) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:202) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:167) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:160) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:78) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.TaskNameResolvingBuildExecuter.execute(TaskNameResolvingBuildExecuter.java:174) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.execution.DelegatingBuildExecuter.execute(DelegatingBuildExecuter.java:54) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.GradleLauncher.doBuildStages(GradleLauncher.java:193) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.GradleLauncher.doBuild(GradleLauncher.java:128) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.GradleLauncher.run(GradleLauncher.java:98) [gradle-core-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.launcher.Main.execute(Main.java:93) [gradle-launcher-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at org.gradle.launcher.Main.main(Main.java:42) [gradle-launcher-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [na:1.6.0_12]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [na:1.6.0_12]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [na:1.6.0_12]
    at java.lang.reflect.Method.invoke(Method.java:597) [na:1.6.0_12]
    at org.gradle.launcher.GradleMain.main(GradleMain.java:50) [gradle-launcher-0.9-20091110044632+0000.jar:0.9-20091110044632+0000]

I should note, that I scrubbed baseDir in this message to not be the real one, but the original stack trace shows the correct baseDir. This is an instance where one subproject depends upon another subproject and both other them are using the war plugin. Not sure that's the issue at this point though.

Aside from changing the fileset()'s to from's and webInf() to webInf

{ from ... }

, there are no other changes in the build.gradle files, which work as expected with gradle 0.8.

I've tracked down the issue to the following dependency statement

dependencies
{
compile(project(':component1'))
{
artifact

{ name = 'component1' ; type = 'jar' }

}
}

This works in 0.8 to get only the jar file instead of the war file which is also part of the exposed artifacts, but now crashes under the 0.9 snapshot.

Of course removing that line allows the build to work, but both the war and jar are included in component2.war which is not desired; hence the whole reason for constraining the actual artifact that is to be depended upon.



 Comments   
Comment by Hans Dockter [ 11/Nov/09 ]

I have tried to reproduce the problem but did not get the above exceptions. Anyhow, there is another way of achieving what you want to achieve. In the war project you could do the following:

usePlugin 'war'
jar.enabled = true

configurations {
   lib // declare some configuration for publishing the jar
}

artifacts {
   lib jar // add the jar to be published by the lib configuration
}

In the consuming project you can do:

dependencies {
   compile project(path: ':component1', configuration: 'lib' ) // If you don't specify a configuration the default configuration is used, which contains the war.
}
Comment by Spencer Allain [ 12/Nov/09 ]

This blows up with a complaint about a null path using latest gradle 0.9 snapshot.

Comment by Spencer Allain [ 12/Nov/09 ]

I've added the attachment as a test case that fails every time for me.

I might adjust to using the alternative configuration mechanism, but it adds a level of inconvenience for the setup that I'm currently modeling.

Consider comp1, comp2, comp3, and comp4.
comp1 produces just a jar file (shared by all)
comp2 produces a jar and a war. Includes comp1 jar.
comp3 produces a jar and a war. Includes comp1 jar and comp2 jar.
comp4 produces 2 wars. War 1 includes comp1.jar. War 2 includes comp2.jar and comp3.jar.

These components are part of a deployable application suite where sometimes they are standalone, and other times they co-exist in a single deployment with each other.

Another solution for me would be to create virtual components called comp2war and comp3war that simply depend upon the normal comp2 and comp3 java plugin components, but that forces more directories and build.gradle files.

I'm trying to identify the "best" model of supporting jar/war situations, as it's only going to get more complex once ears are supported, and sometimes you want a component's jar and other times the war. The recommended method requires looking into the depended-upon component to find out what special configuration name was provided for the jar inclusion rather than just selecting the "jar" type from multiple artifacts.

Comment by Adam Murdoch [ 13/Nov/09 ]

This should be fixed now. The test project builds fine.

Generated at Wed Jun 30 11:37:29 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.