# Java plugin fails to compile with empty path

**URL:** <https://discuss.gradle.org/t/java-plugin-fails-to-compile-with-empty-path/18884>\
**Category:** Help/Discuss\
**Created:** [August 10, 2016, 8:46am UTC](https://discuss.gradle.org/t/java-plugin-fails-to-compile-with-empty-path/18884 "2016-08-10T08:46:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![crazyjavahacking](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/crazyjavahacking/32/5353_2.png) [@crazyjavahacking](https://discuss.gradle.org/u/crazyjavahacking)\
**Post date:** [August 10, 2016, 8:46am UTC](https://discuss.gradle.org/t/java-plugin-fails-to-compile-with-empty-path/18884/1 "2016-08-10T08:46:42Z")

</div>

Using the following `build.gradle`:

```gradle
apply plugin: 'java'

def srcDirs = file('paths.list').text.readLines()
srcDirs.each { srcDirectory ->
    sourceSets {
        main {
            java {
                srcDir srcDirectory
            }
        }
    }
}

```

and `paths.list`:

```gradle
current/path/to/hai
current/path/to/hai2
path/to/hai3
path/to/hai4

```

Executing ‘gradle build’ fails with the following error message:

```gradle
Neither path nor baseDir may be null or empty string. path='' basedir='/home/martin/devel/tmp/gradle-srcdirs-from-file'

```

Gradle Version: 2.14.1  
Operating System: Xubuntu 16.04.1  
Java: 1.8.0\_101 (Oracle Corporation 25.101-b13)

[https://scans.gradle.com/s/c5mu3zjk4omhi](https://scans.gradle.com/s/c5mu3zjk4omhi)

---

<div class="post-metadata">

**Author:** ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)\
**Post date:** [August 10, 2016, 10:21am UTC](https://discuss.gradle.org/t/java-plugin-fails-to-compile-with-empty-path/18884/2 "2016-08-10T10:21:45Z")

</div>

As the error message says, you are trying to add an empty string, probably because your path.list file has a trailing newline.

---

<div class="post-metadata">

**Author:** ![crazyjavahacking](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/crazyjavahacking/32/5353_2.png) [@crazyjavahacking](https://discuss.gradle.org/u/crazyjavahacking)\
**Post date:** [August 10, 2016, 10:52am UTC](https://discuss.gradle.org/t/java-plugin-fails-to-compile-with-empty-path/18884/3 "2016-08-10T10:52:11Z")

</div>

Oh, I completely missed that, thanks.
