Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
adds detection of milestone and release candidate process dependencies
Browse files Browse the repository at this point in the history
if a plugin defines a dependency to e.g.
'dsf-bpe-process-feasibility-0.5.0' the following jars will be used as
dependencies in order:
* dsf-bpe-process-feasibility-0.5.0.jar
* dsf-bpe-process-feasibility-0.5.0-RC#.jar or
dsf-bpe-process-feasibility-0.5.0-M#.jar where # is one or multiple
numeric characters
* dsf-bpe-process-feasibility-0.5.0-SNAPSHOT.jar


fixes #234
  • Loading branch information
hhund committed Aug 19, 2021
1 parent 698841c commit 110d2a9
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import java.util.ServiceLoader;
import java.util.ServiceLoader.Provider;
import java.util.function.BinaryOperator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -47,6 +49,9 @@ private static final class Pair<K, V>
public static final String FILE_DRAFT_SUFIX = "-SNAPSHOT.jar";
public static final String FOLDER_DRAFT_SUFIX = "-SNAPSHOT";

public static final String RC_AND_M_PATTERN_STRING = "^(.+)((-RC[0-9]+)|(-M[0-9]+))\\.jar$";
private static final Pattern RC_AND_M_PATTERN = Pattern.compile(RC_AND_M_PATTERN_STRING);

private static final Logger logger = LoggerFactory.getLogger(ProcessPluginProviderImpl.class);

private final FhirContext fhirContext;
Expand Down Expand Up @@ -247,13 +252,29 @@ private Stream<Path> findDefinition(Map<String, ProcessPluginDefinitionAndClassL
if (byJar != null)
return byJar.getJars().stream();

// -M#.jar or -RC#.jar where # is one or more numeric characters
List<String> fileNames = definitionsByJar.keySet().stream()
.filter(filename -> matchesReleaseCandidateMilestonePatternAndIsDependency(filename, dependency))
.collect(Collectors.toList());
if (fileNames.size() == 1)
return definitionsByJar.get(fileNames.get(0)).getJars().stream();

ProcessPluginDefinitionAndClassLoader bySnapshotJar = definitionsByJar.get(dependency + "-SNAPSHOT.jar");
if (bySnapshotJar != null)
return bySnapshotJar.getJars().stream();

throw new RuntimeException("Dependency " + dependency + " not found");
}

private boolean matchesReleaseCandidateMilestonePatternAndIsDependency(String filename, String dependency)
{
Matcher matcher = RC_AND_M_PATTERN.matcher(filename);
if (matcher.matches())
return matcher.group(1).equals(dependency);
else
return false;
}

private ProcessPluginDefinitionAndClassLoader toJarDefinitionWithDependencies(String definitionClassName,
Path jarFile, List<Path> dependencyJars)
{
Expand Down

0 comments on commit 110d2a9

Please sign in to comment.