brianm/really-executable-jars-maven-plugin

Inconsistent behaviour of programFile with multiple artifacts

Closed this issue · 0 comments

The current handling of programFile seems to make little sense when multiple artifacts exist. Basically, the first artifact that's in the list will be processed just fine, but then the next one would be copied over that same programFile again - except it won't, because the default behaviour of Files.copy() is to just fail if the target exists. Meaning there is no way this code will work with multiple artifacts:

               for (File file : files) {
                    File dir = file.getParentFile();
                    File exec = new File(dir, programFile);
                    Files.copy(file.toPath(), exec.toPath());
                    makeExecutable(exec);
                    if (attachProgramFile) {
                        projectHelper.attachArtifact(project, programFileType, exec);
                    }
                }

I think the sane thing to do is to bail out when multiple artifacts are encountered and programFile is set, instead of a futile loop.