diff --git a/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/LicensesTask.groovy b/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/LicensesTask.groovy index 3df808a3..408782a1 100644 --- a/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/LicensesTask.groovy +++ b/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/LicensesTask.groovy @@ -138,6 +138,10 @@ class LicensesTask extends DefaultTask { } protected void addGooglePlayServiceLicenses(File artifactFile) { + if (artifactFile.isDirectory()) { + return + } + ZipFile licensesZip = new ZipFile(artifactFile) JsonSlurper jsonSlurper = new JsonSlurper() diff --git a/oss-licenses-plugin/src/test/java/com/google/android/gms/oss/licenses/plugin/LicensesTaskTest.java b/oss-licenses-plugin/src/test/java/com/google/android/gms/oss/licenses/plugin/LicensesTaskTest.java index 18c72aec..66f63a8c 100644 --- a/oss-licenses-plugin/src/test/java/com/google/android/gms/oss/licenses/plugin/LicensesTaskTest.java +++ b/oss-licenses-plugin/src/test/java/com/google/android/gms/oss/licenses/plugin/LicensesTaskTest.java @@ -282,6 +282,15 @@ public void testAddGooglePlayServiceLicenses_withoutDuplicate() throws IOExcepti assertTrue(licensesTask.licensesMap.containsKey("JSR 305")); } + @Test + public void testAddGooglePlayServiceLicenses_artifactLocationIsDirectory() throws IOException { + try { + licensesTask.addGooglePlayServiceLicenses(licensesTask.getOutputDir()); + } catch (Exception e) { + fail("This test should not throw an Exception."); + } + } + @Test public void testAppendLicense() throws IOException { licensesTask.appendLicense("license1", "test".getBytes(UTF_8));