public ArtifactVersion matchVersion( List<ArtifactVersion> versions ) { // TODO could be more efficient by sorting the list and then moving along the restrictions in order? ArtifactVersion matched = null; for ( ArtifactVersion version : versions ) { if ( containsVersion( version ) ) { // valid - check if it is greater than the currently matched version if ( matched == null || version.compareTo( matched ) > 0 ) { matched = version; } } } return matched; }
public ArtifactVersion matchVersion( List<ArtifactVersion> versions ) { // TODO could be more efficient by sorting the list and then moving along the restrictions in order? ArtifactVersion matched = null; for ( ArtifactVersion version : versions ) { if ( containsVersion( version ) ) { // valid - check if it is greater than the currently matched version if ( matched == null || version.compareTo( matched ) > 0 ) { matched = version; } } } return matched; }
private boolean matchJdkVersionRange( String jdk ) throws InvalidVersionSpecificationException { VersionRange jdkVersionRange = VersionRange.createFromVersionSpec( convertJdkToMavenVersion( jdk ) ); DefaultArtifactVersion jdkVersion = new DefaultArtifactVersion( convertJdkToMavenVersion( getJdkVersion() ) ); return jdkVersionRange.containsVersion( jdkVersion ); }
private boolean matchJdkVersionRange( String jdk ) throws InvalidVersionSpecificationException { VersionRange jdkVersionRange = VersionRange.createFromVersionSpec( convertJdkToMavenVersion( jdk ) ); DefaultArtifactVersion jdkVersion = new DefaultArtifactVersion( convertJdkToMavenVersion( getJdkVersion() ) ); return jdkVersionRange.containsVersion( jdkVersion ); }
@Override public boolean matches( String requirement ) { try { VersionRange range = VersionRange.createFromVersionSpec( requirement ); if ( range.hasRestrictions() ) { return range.containsVersion( version ); } else { return range.getRecommendedVersion().compareTo( version ) == 0; } } catch ( InvalidVersionSpecificationException ex ) { //TODO error reporting ex.printStackTrace(); return false; } }
if ( !parentRange.containsVersion( new DefaultArtifactVersion( version ) ) )
String version = pluginBundleIdentifierToPluginBundle.get(pluginBundleIdentifier).getPluginBundleVersion().getVersion(); ArtifactVersion artifactVersion = new DefaultArtifactVersion(version); if (versionRange.containsVersion(artifactVersion)) {
if (versionRange.containsVersion(artifactVersion)) {
if (bimserverVersion == null || versionRange.containsVersion(bimserverVersion) || (bimserverVersion.getQualifier() != null && bimserverVersion.getQualifier().equals("SNAPSHOT"))) {
private MavenRuntime newMavenRuntime(Module[] modules) throws Exception { for (Map.Entry<VersionRange, RuntimeFactory> entry : FACTORIES.entrySet()) { if (entry.getKey().containsVersion(MAVEN_VERSION)) { return entry.getValue().newInstance(modules); } } throw new AssertionError(String.format("Maven version %s is not supported, supprted versions: %s", MAVEN_VERSION, FACTORIES.entrySet())); }
public ArtifactVersion matchVersion( List<ArtifactVersion> versions ) { // TODO: could be more efficient by sorting the list and then moving along the restrictions in order? ArtifactVersion matched = null; for ( ArtifactVersion version : versions ) { if ( containsVersion( version ) ) { // valid - check if it is greater than the currently matched version if ( matched == null || version.compareTo( matched ) > 0 ) { matched = version; } } } return matched; }
/** * Ensure <code>artifactName</code> matches version <code>versionSpec</code>. */ private void checkVersion(String artifactName, String versionSpec, Artifact artifact) throws MojoExecutionException { VersionRange range; try { range = VersionRange.createFromVersionSpec(versionSpec); if (!range.containsVersion(new DefaultArtifactVersion(artifact.getVersion()))) { throw new MojoExecutionException( "JUnit4 plugin requires " + artifactName + " in version " + versionSpec + " among project dependencies, you declared: " + artifact.getVersion()); } } catch (InvalidVersionSpecificationException e) { throw new RuntimeException(e); } }
@Override public AbstractBuildParticipant getMojoExecutionBuildParticipant(MojoExecution execution) { //<proc></proc> is not available for maven-compiler-plugin < 2.2 if(VALID_COMPILER_PLUGIN_RANGE.containsVersion(new DefaultArtifactVersion(execution.getVersion()))) { // Disabled for now return new MavenCompilerBuildParticipant(execution); } return null; }
static boolean isWithinVersionSpec( @Nullable Artifact artifact, @Nonnull String versionSpec ) { if ( artifact == null ) { return false; } try { VersionRange range = createFromVersionSpec( versionSpec ); try { return range.containsVersion( artifact.getSelectedVersion() ); } catch ( NullPointerException e ) { return range.containsVersion( new DefaultArtifactVersion( artifact.getBaseVersion() ) ); } } catch ( InvalidVersionSpecificationException | OverConstrainedVersionException e ) { throw new RuntimeException( "Bug in plugin. Please report with stacktrace" ); } }
private Artifact getTestNgArtifact() throws MojoExecutionException { Artifact artifact = getProjectArtifactMap().get( getTestNGArtifactName() ); Artifact projectArtifact = project.getArtifact(); String projectArtifactName = projectArtifact.getGroupId() + ":" + projectArtifact.getArtifactId(); if ( artifact != null ) { VersionRange range = createVersionRange(); if ( !range.containsVersion( new DefaultArtifactVersion( artifact.getVersion() ) ) ) { throw new MojoExecutionException( "TestNG support requires version 4.7 or above. You have declared version " + artifact.getVersion() ); } } else if ( projectArtifactName.equals( getTestNGArtifactName() ) ) { artifact = projectArtifact; } return artifact; }
private Artifact getTestNgArtifact() throws MojoExecutionException { Artifact artifact = getProjectArtifactMap().get( getTestNGArtifactName() ); Artifact projectArtifact = project.getArtifact(); String projectArtifactName = projectArtifact.getGroupId() + ":" + projectArtifact.getArtifactId(); if ( artifact != null ) { VersionRange range = createVersionRange(); if ( !range.containsVersion( new DefaultArtifactVersion( artifact.getVersion() ) ) ) { throw new MojoExecutionException( "TestNG support requires version 4.7 or above. You have declared version " + artifact.getVersion() ); } } else if ( projectArtifactName.equals( getTestNGArtifactName() ) ) { artifact = projectArtifact; } return artifact; }
private static boolean isWithin(String version, VersionRange versionRange) { ArtifactVersion artifactVersion = new DefaultArtifactVersion(version); boolean within = false; if (versionRange != null) { ArtifactVersion recommendedVersion = versionRange.getRecommendedVersion(); // treat recommended version as minimum version within = recommendedVersion != null ? VersionUtil.isLessThanOrEqualTo(recommendedVersion, artifactVersion) : versionRange.containsVersion(artifactVersion); } return within; }
/** * Checks whether the currently running Maven satisfies the specified version (range). * * @param version The version range to test for, must not be <code>null</code>. * @return <code>true</code> if the current Maven version matches the specified version range, <code>false</code> * otherwise. */ protected boolean isMavenVersion( String version ) { try { VersionRange versionRange = VersionRange.createFromVersionSpec( version ); ArtifactVersion mavenVersion = runtimeInformation.getApplicationVersion(); return versionRange.containsVersion( mavenVersion ); } catch ( InvalidVersionSpecificationException e ) { throw new IllegalArgumentException( e.getMessage() ); } }
public boolean matches( String requirement ) { try { VersionRange range = VersionRange.createFromVersionSpec(requirement); if (range.hasRestrictions()) { return range.containsVersion(version); } else { return range.getRecommendedVersion().compareTo(version) == 0; } } catch (InvalidVersionSpecificationException ex) { //TODO error reporting ex.printStackTrace(); return false; } } }
/** * Checks whether this ModuleDependency is satisfied by the dependency of the given ModuleDependency. * If the version string is a defined version, then it does a comparison. If the version string * is a version range if parses this and caters for this. * * @param other The dependency to check for. * @return true if contained false otherwise. */ public boolean contains(ModuleDependency other) { if (other == null || !getName().equals(other.getName())) return false; try { return isVersionRange() ? getVersionAsRange().containsVersion(other.parseVersion()) : parseVersion().compareTo(other.parseVersion()) == 0; } catch (InvalidVersionSpecificationException ivse) { return false; } }