[docker] place spec files in their respective folder. Fixes
@@ -410,33 +410,37 @@ public class DockerToolProcessor extends AbstractRepositoryToolProcessor<Docker>
if (tool.getActiveSpecs().isEmpty()) {
for (String imageName : tool.getImageNames()) {
- copyDockerfiles(packageDirectory, applyTemplate(imageName, props), directory, tool);
+ copyDockerfiles(packageDirectory, applyTemplate(imageName, props), directory, tool, false);
}
} else {
for (DockerSpec spec : tool.getActiveSpecs()) {
Map<String, Object> newProps = fillSpecProps(distribution, props, spec);
for (String imageName : spec.getImageNames()) {
- copyDockerfiles(packageDirectory.resolve(spec.getName()), applyTemplate(imageName, newProps), directory, spec);
+ copyDockerfiles(packageDirectory.resolve(spec.getName()), applyTemplate(imageName, newProps), directory, spec, true);
}
}
}
}
- private void copyDockerfiles(Path source, String imageName, Path directory, DockerConfiguration docker) throws IOException {
+ private void copyDockerfiles(Path source, String imageName, Path directory, DockerConfiguration docker, boolean isSpec) throws IOException {
Path destination = directory;
- if (tool.getRepository().isVersionedSubfolders()) {
String[] parts = imageName.split("/");
parts = parts[parts.length - 1].split(":");
- destination = directory.resolve(parts[1]);
+ if (isSpec) {
+ destination = directory.resolve(parts[0]);
}
- Files.createDirectories(destination);
- prepareWorkingCopy(source, destination);
+ if (tool.getRepository().isVersionedSubfolders()) {
+ destination = directory.resolve(parts[1]);
+ }
- if (!docker.isUseLocalArtifact()) {
Path assembly = destination.resolve("assembly");
FileUtils.deleteFiles(assembly);
- }
+
+ Files.createDirectories(destination);
+ prepareWorkingCopy(source, destination,
+ path -> !docker.isUseLocalArtifact() &&
+ "assembly".equals(path.getFileName().toString()));
}
}
