private void mergeModuleArtifacts(Module existingModule, Module moduleToMerge) { List<Artifact> existingArtifacts = existingModule.getArtifacts(); List<Artifact> artifactsToMerge = moduleToMerge.getArtifacts(); if (existingArtifacts == null || existingArtifacts.isEmpty()) { existingModule.setArtifacts(artifactsToMerge); return; } if (artifactsToMerge == null || artifactsToMerge.isEmpty()) { return; } for (Artifact artifactToMerge : artifactsToMerge) { Artifact foundArtifact = findArtifact(existingArtifacts, artifactToMerge.getName()); if (foundArtifact == null) { existingArtifacts.add(artifactToMerge); } else { if (StringUtils.isBlank(foundArtifact.getMd5()) && StringUtils.isBlank(foundArtifact.getSha1())) { foundArtifact.setType(artifactToMerge.getType()); foundArtifact.setMd5(artifactToMerge.getMd5()); foundArtifact.setSha1(artifactToMerge.getSha1()); foundArtifact.setProperties(artifactToMerge.getProperties()); } } } }
private Set<DeployDetails> prepareDeployableArtifacts(Build build, Map<String, DeployDetails> deployableArtifactBuilders) { Set<DeployDetails> deployableArtifacts = Sets.newLinkedHashSet(); List<Module> modules = build.getModules(); for (Module module : modules) { List<Artifact> artifacts = module.getArtifacts(); if(artifacts!=null){ for (Artifact artifact : artifacts) { String artifactId = BuildInfoExtractorUtils.getArtifactId(module.getId(), artifact.getName()); DeployDetails deployable = deployableArtifactBuilders.get(artifactId); if (deployable != null) { File file = deployable.getFile(); setArtifactChecksums(file, artifact); deployableArtifacts.add(new DeployDetails.Builder().artifactPath(deployable.getArtifactPath()). file(file).md5(artifact.getMd5()).sha1(artifact.getSha1()). addProperties(deployable.getProperties()). targetRepository(deployable.getTargetRepository()).build()); } } } } return deployableArtifacts; }