From 4d5a21fe4821c14b13e98951f2f4b9d3079b25e6 Mon Sep 17 00:00:00 2001 From: BO8979 Date: Fri, 6 Dec 2019 11:27:20 -0600 Subject: [PATCH] https://github.com/mojohaus/rpm-maven-plugin/issues/118 Do not write out files for mappings with no source definitions. --- src/main/java/org/codehaus/mojo/rpm/SpecWriter.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/rpm/SpecWriter.java b/src/main/java/org/codehaus/mojo/rpm/SpecWriter.java index 28f45a9a..b4f58dbb 100644 --- a/src/main/java/org/codehaus/mojo/rpm/SpecWriter.java +++ b/src/main/java/org/codehaus/mojo/rpm/SpecWriter.java @@ -18,8 +18,9 @@ * specific language governing permissions and limitations * under the License. */ - -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; import java.util.Collection; import java.util.List; import java.util.Map; @@ -238,8 +239,8 @@ private void writeFiles() scanner.setExcludes( null ); scanner.scan(); - if ( scanner.isEverythingIncluded() && links.isEmpty() && map.isDirectoryIncluded() - && !map.isRecurseDirectories() ) + final boolean noFiles = map.getSources().isEmpty() || (scanner.isEverythingIncluded() && links.isEmpty()); + if ( noFiles && map.isDirectoryIncluded() && !map.isRecurseDirectories() ) { log.debug( "writing attribute string for directory: " + destination ); spec.println( attrString + " \"" + destination + "\"" ); @@ -272,7 +273,7 @@ private void writeFiles() } // only list files if requested (directoryIncluded == false) or we have to - if ( !( map.isDirectoryIncluded() && scanner.isEverythingIncluded() && links.isEmpty() && !map.isRecurseDirectories()) ) + if ( !map.isDirectoryIncluded() || !noFiles ) { final String[] files = scanner.getIncludedFiles();