Skip to content

Commit

Permalink
Merge pull request #7 from confluentinc/disable-not-range
Browse files Browse the repository at this point in the history
skip when verion range is not valid
  • Loading branch information
xli1996 authored Mar 9, 2021
2 parents 53d31f1 + 34bf827 commit 3b07f1b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/it/it-resolve-kafka-range-test-003/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:resolve-kafka-range
52 changes: 52 additions & 0 deletions src/it/it-resolve-kafka-range-test-003/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>localhost</groupId>
<artifactId>it-lex-order-test-001</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Update a dependency to the latest version</name>
<description>
This is a simple IT test to test that maven ce ccs kafka version compare do not
follow lexi order.
</description>

<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>kafka-clients</artifactId>
<version>${ce.kafka.version}</version>
</dependency>
</dependencies>

<properties>
<ce.kafka.version>6.1.0-ccs</ce.kafka.version>
<kafka.version>6.1.0-ce</kafka.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<groupId>localhost</groupId>
<artifactId>kafka-clients</artifactId>
<versionRange>6.1.0</versionRange>
<skip>true</skip>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>resolve-kafka-range</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
5 changes: 5 additions & 0 deletions src/it/it-resolve-kafka-range-test-003/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def buildLog = new File( basedir, "build.log")

assert buildLog.text.contains( '[INFO] Skip version range resolve since property is not a valid range' )

return true
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ public String toString() {

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (!isVersionRange(versionRange)) {
skip = true;
getLog().info("Skip version range resolve since property is not a valid range");
}
if(!skip) {
VersionRangeRequest request = new VersionRangeRequest();
request.setRepositories(remoteRepositories);
Expand Down Expand Up @@ -386,5 +390,12 @@ private static boolean isCCS(String version) {

private static boolean isCE(String version) {
return version.endsWith(Strings.CE_QUALIFIER.toString());
}
}

private static boolean isVersionRange(String versionRange) {
boolean startValid = versionRange.startsWith("[") || versionRange.startsWith("(");
boolean endValid = versionRange.endsWith("]") || versionRange.endsWith(")");
return startValid && endValid;
}

}

0 comments on commit 3b07f1b

Please sign in to comment.