| 1 | |
package com.aurea.maven.plugins.sonic.esb; |
| 2 | |
|
| 3 | |
import java.util.HashSet; |
| 4 | |
|
| 5 | |
import org.apache.maven.plugin.MojoExecutionException; |
| 6 | |
import org.apache.maven.plugin.MojoFailureException; |
| 7 | |
|
| 8 | |
import com.aurea.maven.plugins.sonic.utils.ProjectAnalyzer; |
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | 0 | public class EsbDependenciesMojo extends AbstractESBMojo { |
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
protected boolean validateDependencies; |
| 26 | |
|
| 27 | |
|
| 28 | |
@Override |
| 29 | |
protected void doExecute() throws MojoExecutionException, MojoFailureException { |
| 30 | |
|
| 31 | 0 | if (validateDependencies) { |
| 32 | 0 | validateDependencies(); |
| 33 | |
} else { |
| 34 | 0 | getLog().warn("Dependency validation will be skipped"); |
| 35 | |
} |
| 36 | |
|
| 37 | 0 | getLog().info("Depenency validation complete"); |
| 38 | 0 | } |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
private void validateDependencies() throws MojoExecutionException { |
| 48 | |
|
| 49 | |
|
| 50 | 0 | getLog().info("Validating process dependencies"); |
| 51 | |
|
| 52 | |
|
| 53 | 0 | HashSet<String> localProcessNames = ProjectAnalyzer.getProcessNames(getSonicEsbSourceDirectory().getAbsolutePath()); |
| 54 | 0 | HashSet<String> subProcesssNames = ProjectAnalyzer.getSubProcessesOfProcesses(getSonicEsbSourceDirectory()); |
| 55 | 0 | HashSet<String> dependencyProcessNames = getDependencyProcessNames(); |
| 56 | |
|
| 57 | 0 | getLog().debug("Local processes found: " + localProcessNames.toString()); |
| 58 | 0 | getLog().debug("Sub-processes found: " + subProcesssNames.toString()); |
| 59 | 0 | getLog().debug("Dependency processes found: " + dependencyProcessNames.toString()); |
| 60 | |
|
| 61 | |
|
| 62 | 0 | HashSet<String> knownProcesses = new HashSet<String>(); |
| 63 | 0 | knownProcesses.addAll(localProcessNames); |
| 64 | 0 | knownProcesses.addAll(dependencyProcessNames); |
| 65 | |
|
| 66 | |
|
| 67 | 0 | if (!knownProcesses.containsAll(subProcesssNames)) { |
| 68 | |
|
| 69 | 0 | HashSet<String> unknownProcesses = new HashSet<String>(); |
| 70 | 0 | unknownProcesses.addAll(subProcesssNames); |
| 71 | 0 | unknownProcesses.removeAll(knownProcesses); |
| 72 | |
|
| 73 | 0 | throw new MojoExecutionException("Not all sub-processes are known. " |
| 74 | |
+ "Please add dependencies containing the following processes: " + unknownProcesses.toString()); |
| 75 | |
} |
| 76 | |
|
| 77 | 0 | } |
| 78 | |
} |