Skip to content

Commit

Permalink
Merge pull request #13 from TomasHofman/multiple-input-params
Browse files Browse the repository at this point in the history
Multiple input params
  • Loading branch information
TomasHofman authored May 22, 2024
2 parents 02f8649 + 8d3c5f4 commit 390b739
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class VerifyDependenciesMojoIT {
@MavenTest
void unaligned_test_case(MavenExecutionResult result) throws Exception {
assertThat(result).isFailure();
assertThat(result).out().warn().contains(
assertThat(result).out().error().contains(
"Dependency org.jboss.marshalling:jboss-marshalling:2.0.6.Final doesn't match expected version 2.0.9.Final-redhat-00001",
"Dependency commons-io:commons-io:2.10.0 doesn't match expected version 2.10.1.redhat-00001",
"Dependency io.undertow:undertow-core:2.2.5.Final doesn't match expected version 2.2.6.Final"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,6 @@ public abstract class AbstractChannelMojo extends AbstractMojo {
protected ChannelSession channelSession;

protected void initChannelSession() throws MojoExecutionException {
int numberOfSources = 0;
if (StringUtils.isNotBlank(channelFile)) numberOfSources++;
if (StringUtils.isNotBlank(channelGAV)) numberOfSources++;
if (StringUtils.isNotBlank(manifestFile)) numberOfSources++;
if (StringUtils.isNotBlank(manifestGAV)) numberOfSources++;
if (numberOfSources > 1) {
throw new MojoExecutionException("Exactly one of [channelFile, channelGAV, manifestFile, manifestGAV] has to be given.");
}

// Do not enforce this for now, repositories are also read from project pom.xml currently.
/*if ((StringUtils.isNotBlank(manifestFile) || StringUtils.isNotBlank(manifestGAV)) && remoteRepositories.isEmpty()) {
throw new MojoExecutionException("The remoteRepositories property is mandatory when manifest is given.");
}*/

try {
if (StringUtils.isNotBlank(channelFile)) {
String[] paths = channelFile.split(",");
Expand All @@ -120,19 +106,22 @@ protected void initChannelSession() throws MojoExecutionException {
getLog().info("Reading channel file " + channelFilePath);
channels.add(ChannelMapper.from(channelFilePath.toUri().toURL()));
}
} else if (StringUtils.isNotBlank(channelGAV)) {
}
if (StringUtils.isNotBlank(channelGAV)) {
String[] gavs = channelGAV.split(",");
for (String gav: gavs) {
channels.addAll(resolveChannelsFromGav(gav));
}
} else if (StringUtils.isNotBlank(manifestFile)) {
}
if (StringUtils.isNotBlank(manifestFile)) {
String[] paths = manifestFile.split(",");
for (String path: paths) {
URL manifestUrl = Path.of(path).toUri().toURL();
ChannelManifestCoordinate coordinate = new ChannelManifestCoordinate(manifestUrl);
channels.add(new Channel("a-channel", null, null, null, coordinate, null, null));
}
} else if (StringUtils.isNotBlank(manifestGAV)) {
}
if (StringUtils.isNotBlank(manifestGAV)) {
String[] gavs = manifestGAV.split(",");
for (String gav: gavs) {
ChannelManifestCoordinate coordinate = toManifestCoordinate(gav);
Expand All @@ -144,7 +133,9 @@ protected void initChannelSession() throws MojoExecutionException {
repositories.addAll(createRepositories(remoteRepositories));
channels.add(new Channel("a-channel", null, null, repositories, coordinate, null, null));
}
} else {
}

if (channels.isEmpty()) {
throw new MojoExecutionException("No channel or manifest specified.");
}
} catch (MalformedURLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
unalignedDependencies.forEach(pair -> {
ArtifactRef dep = pair.getLeft();
String v = pair.getRight();
getLog().warn(String.format("Dependency %s:%s:%s doesn't match expected version %s",
getLog().error(String.format("Dependency %s:%s:%s doesn't match expected version %s",
dep.getGroupId(), dep.getArtifactId(), dep.getVersionString(), v));
});
if (failBuild) {
Expand Down

0 comments on commit 390b739

Please sign in to comment.