Java Code Examples for org.apache.maven.artifact.versioning.VersionRange#createFromVersionSpec()

The following examples show how to use org.apache.maven.artifact.versioning.VersionRange#createFromVersionSpec() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CdiContainerUnderTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
/**
 * Verify if the runtime is using the following CdiImplementation
 * 
 * @param cdiImplementation
 * @param versionRange
 *            optional - If not defined it will used the range defined on {@link CdiImplementation}
 * @return
 * @throws InvalidVersionSpecificationException
 */
public static boolean isCdiVersion(CdiImplementation cdiImplementation, String versionRange)
    throws InvalidVersionSpecificationException
{

    Class implementationClass = tryToLoadClassForName(cdiImplementation.getImplementationClassName());

    if (implementationClass == null)
    {
        return false;
    }

    VersionRange range = VersionRange.createFromVersionSpec(versionRange == null ? cdiImplementation
            .getVersionRange() : versionRange);
    String containerVersion = getJarSpecification(implementationClass);
    return containerVersion != null && range.containsVersion(new DefaultArtifactVersion(containerVersion));
}
 
Example 2
Source File: DataflowDependencyManager.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the encoded version range from the given project's POM, or {@code null} if no version
 * is specified.
 * 
 * @return the version range or {@code null} if a version range is not specified
 * @throws IllegalStateException if the encoded version range is not a valid version specification
 */
private VersionRange getActualDataflowVersionRange(IProject project) {
  Model model = getModelFromProject(project);
  if (model != null) {
    Dependency dependency = getDataflowDependencyFromModel(model);
    if (dependency != null) {
      String version = dependency.getVersion();
      if (!Strings.isNullOrEmpty(version)) {
        try {
          return VersionRange.createFromVersionSpec(version);
        } catch (InvalidVersionSpecificationException ex) {
          String message =
              String.format("Could not create version range from existing version %s", version);
          throw new IllegalStateException(message, ex);
        }
      }
    }
  }
  return null;
}
 
Example 3
Source File: ArtifactVersionsTest.java    From versions-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testSmokes()
    throws Exception
{
    ArtifactVersion[] versions = versions( "1.0", "3.0", "1.1", "1.0", "1.0.1" );
    final DefaultArtifact artifact =
        new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec( "[1.0,3.0]" ), "foo", "bar",
                             "jar", new DefaultArtifactHandler() );
    ArtifactVersions instance =
        new ArtifactVersions( artifact, Arrays.asList( versions ), new MavenVersionComparator() );
    assertEquals( "artifact", instance.getArtifactId() );
    assertEquals( "group", instance.getGroupId() );
    assertArrayEquals(
        versions( "1.0", "1.0.1", "1.1", "3.0" ),
        instance.getVersions() );
    assertArrayEquals( versions( "3.0" ),
                       instance.getVersions( new DefaultArtifactVersion( "1.1" ), null ) );
    assertArrayEquals(
        versions( "1.1", "3.0" ),
        instance.getVersions( new DefaultArtifactVersion( "1.0.1" ), null ) );
    assertEquals( new DefaultArtifactVersion( "1.1" ),
                  instance.getNewestVersion( new DefaultArtifactVersion( "1.0" ),
                                             new DefaultArtifactVersion( "3.0" ) ) );
    assertNull(
        instance.getNewestVersion( new DefaultArtifactVersion( "1.1" ), new DefaultArtifactVersion( "3.0" ) ) );
}
 
Example 4
Source File: ConfluenceDeployMojo.java    From maven-confluence-plugin with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param projectId
 * @param dependencyManagement
 * @return
 * @throws ProjectBuildingException
 */
private Map<String,Artifact> createManagedVersionMap(String projectId, DependencyManagement dependencyManagement) throws ProjectBuildingException {
    Map<String,Artifact> map;
    if (dependencyManagement != null && dependencyManagement.getDependencies() != null) {
        map = new HashMap<>();
        for (Dependency d : dependencyManagement.getDependencies()) {
            try {
                VersionRange versionRange = VersionRange.createFromVersionSpec(d.getVersion());
                Artifact artifact = factory.createDependencyArtifact(d.getGroupId(), d.getArtifactId(),
                        versionRange, d.getType(), d.getClassifier(),
                        d.getScope());
                map.put(d.getManagementKey(), artifact);
            } catch (InvalidVersionSpecificationException e) {
                throw new ProjectBuildingException(projectId, "Unable to parse version '" + d.getVersion()
                        + "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), e);
            }
        }
    } else {
        map = Collections.emptyMap();
    }
    return map;
}
 
Example 5
Source File: ResolvableDependency.java    From java-specialagent with Apache License 2.0 6 votes vote down vote up
List<Dependency> resolveVersions(final MavenProject project, final Log log) throws InvalidVersionSpecificationException, MojoExecutionException {
  if (resolvedVersions != null)
    return resolvedVersions;

  if (isSingleVersion())
    return resolvedVersions = Collections.singletonList(MavenUtil.newDependency(getGroupId(), getArtifactId(), getVersion()));

  final ResolvableDependency versionDependency = isOwnVersion() ? this : ResolvableDependency.parse(getVersion());
  resolvedVersions = new ArrayList<>();

  final SortedSet<DefaultArtifactVersion> versions = resolveVersions(project, log, versionDependency);
  final VersionRange versionRange = VersionRange.createFromVersionSpec(versionDependency.getVersion());
  for (final DefaultArtifactVersion version : versions)
    if (versionRange.containsVersion(version))
      resolvedVersions.add(MavenUtil.newDependency(getGroupId(), getArtifactId(), version.toString()));

  return resolvedVersions;
}
 
Example 6
Source File: DefaultVersionsHelper.java    From versions-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePluginRepositories )
    throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException
{
    getLog().debug( "Checking "
        + ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() )
        + " for updates newer than " + dependency.getVersion() );
    VersionRange versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() );

    return lookupArtifactVersions( createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(),
                                                             versionRange, dependency.getType(),
                                                             dependency.getClassifier(), dependency.getScope() ),
                                   usePluginRepositories );
}
 
Example 7
Source File: RangeResolver.java    From pom-manipulation-ext with Apache License 2.0 5 votes vote down vote up
private void handleVersionWithRange( Plugin p )
{
    try
    {
        VersionRange versionRange = VersionRange.createFromVersionSpec( p.getVersion() );

        // If its a range then try to use a matching version...
        if ( versionRange.hasRestrictions() )
        {
            final List<ArtifactVersion> versions = getVersions( new SimpleProjectRef( p.getGroupId(), p.getArtifactId() ) );
            final ArtifactVersion result = versionRange.matchVersion( versions );

            logger.debug( "Resolved range for plugin {} got versionRange {} and potential replacement of {} ", p, versionRange, result );

            if ( result != null )
            {
                p.setVersion( result.toString() );
            }
            else
            {
                logger.warn( "Unable to find replacement for range." );
            }
        }
    }
    catch ( InvalidVersionSpecificationException e )
    {
        throw new ManipulationUncheckedException( new ManipulationException( "Invalid range", e ) );
    }
}
 
Example 8
Source File: RangeResolver.java    From pom-manipulation-ext with Apache License 2.0 5 votes vote down vote up
private void handleVersionWithRange( Dependency d )
{
    try
    {
        VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );

        // If its a range then try to use a matching version...
        if ( versionRange.hasRestrictions() )
        {
            final List<ArtifactVersion> versions = getVersions( new SimpleProjectRef( d.getGroupId(), d.getArtifactId() ) );
            final ArtifactVersion result = versionRange.matchVersion( versions );

            logger.debug( "Resolved range for dependency {} got versionRange {} and potential replacement of {} ", d, versionRange, result );

            if ( result != null )
            {
                d.setVersion( result.toString() );
            }
            else
            {
                logger.warn( "Unable to find replacement for range." );
            }
        }
    }
    catch ( InvalidVersionSpecificationException e )
    {
        throw new ManipulationUncheckedException( new ManipulationException( "Invalid range", e ) );
    }
}
 
Example 9
Source File: ArtifactInfo.java    From pgpverify-maven-plugin with Apache License 2.0 5 votes vote down vote up
public ArtifactInfo(String strArtifact, KeyInfo keyInfo) {

        String[] split = strArtifact.split(":");
        String groupId = split.length > 0 ? split[0].trim().toLowerCase(Locale.US) : "";
        String artifactId = split.length > 1 ? split[1].trim().toLowerCase(Locale.US) : "";

        String packaging = "";
        String version = "";

        if (split.length == 3) {
            String item = split[2].trim().toLowerCase(Locale.US);
            if (PACKAGING.matcher(item).matches()) {
                packaging = item;
            } else {
                version = item;
            }
        } else if (split.length == 4) {
            packaging = split[2].trim().toLowerCase(Locale.US);
            version = split[3].trim().toLowerCase(Locale.US);
        } else {
            packaging = "";
        }


        try {
            groupIdPattern = Pattern.compile(patternPrepare(groupId));
            artifactIdPattern = Pattern.compile(patternPrepare(artifactId));
            packagingPattern = Pattern.compile(patternPrepare(packaging));
            versionRange = VersionRange.createFromVersionSpec(versionSpecPrepare(version));
        } catch (InvalidVersionSpecificationException | PatternSyntaxException e) {
            throw new IllegalArgumentException("Invalid artifact definition: " + strArtifact, e);
        }
        this.keyInfo = keyInfo;
    }
 
Example 10
Source File: ArtifactVersionsTest.java    From versions-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void test4DigitVersions() throws Exception {
    ArtifactVersion[] versions = versions( "1.0.0.1", "1.0.0.2", "2.121.2.1", "2.100.0.1", "3.1.0.1", "1.1.1");
    final DefaultArtifact artifact =
            new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec( "[1.0,3.0]" ), "foo", "bar",
                                 "jar", new DefaultArtifactHandler() );
    // TODO This should also work for the MavenVersionComparator when using maven 3.x libraries
    ArtifactVersions instance =
            new ArtifactVersions(artifact, Arrays.asList( versions ), new MercuryVersionComparator() );
    assertEquals( "artifact", instance.getArtifactId() );
    assertEquals( "group", instance.getGroupId() );
    assertThat(instance.getVersions(),
               Matchers.arrayContaining(versions( "1.0.0.1", "1.0.0.2", "1.1.1", "2.100.0.1", "2.121.2.1",
                                                  "3.1.0.1" )));
    assertThat(instance.getVersions( new DefaultArtifactVersion( "1.1" ), null ),
               Matchers.arrayContaining(versions("1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1")));

    assertThat(instance.getVersions( new DefaultArtifactVersion( "1.0.0.2" ), null ),
                      //Matchers.arrayContaining(versions("1.1.1", "2.121.2.1", "2.100.0.1", "3.1.0.1")));
               Matchers.arrayContaining(versions("1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1")));

    assertEquals( new DefaultArtifactVersion( "2.121.2.1" ),
                  instance.getNewestVersion( new DefaultArtifactVersion( "1.0" ),
                                             new DefaultArtifactVersion( "3.0" ) ) );
    assertNull(
            instance.getNewestVersion( new DefaultArtifactVersion( "1.1.1" ),
                                       new DefaultArtifactVersion( "2.0" ) ) );
}
 
Example 11
Source File: AbstractVersionsReportRenderer.java    From versions-maven-plugin with Apache License 2.0 5 votes vote down vote up
private Set<String> getVersionsInRange( Property property, PropertyVersions versions,
                                        ArtifactVersion[] artifactVersions )
{
    VersionRange range;
    Set<String> rangeVersions = new HashSet<>();
    ArtifactVersion[] tmp;
    if ( property.getVersion() != null )
    {
        try
        {
            range = VersionRange.createFromVersionSpec( property.getVersion() );
            tmp = versions.getAllUpdates( range );
        }
        catch ( InvalidVersionSpecificationException e )
        {
            tmp = artifactVersions;
        }
    }
    else
    {
        tmp = artifactVersions;
    }
    for ( int i = 0; i < tmp.length; i++ )
    {
        rangeVersions.add( tmp[i].toString() );
    }
    return rangeVersions;
}
 
Example 12
Source File: PomHelper.java    From versions-maven-plugin with Apache License 2.0 5 votes vote down vote up
private static VersionRange createVersionRange( String versionOrRange )
    throws InvalidVersionSpecificationException
{
    VersionRange versionRange = VersionRange.createFromVersionSpec( versionOrRange );
    if ( versionRange.getRecommendedVersion() != null )
    {
        versionRange = VersionRange.createFromVersionSpec( "[" + versionOrRange + "]" );
    }
    return versionRange;
}
 
Example 13
Source File: DataflowDependencyManager.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private static VersionRange allVersions() {
  try {
    return VersionRange.createFromVersionSpec("[1.0.0,)");
  } catch (InvalidVersionSpecificationException e) {
    throw new IllegalStateException(
        "Could not create constant version Range [1.0.0,)", e);
  }
}
 
Example 14
Source File: ArtifactRetrieverIntegrationTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetGuava19() throws InvalidVersionSpecificationException {
  VersionRange range = VersionRange.createFromVersionSpec("[1.0,19.0]");
  ArtifactVersion guava =
      ArtifactRetriever.DEFAULT.getLatestReleaseVersion("com.google.guava", "guava", range);
  Assert.assertEquals(19, guava.getMajorVersion());
  Assert.assertEquals(0, guava.getMinorVersion());
}
 
Example 15
Source File: MajorVersionTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testInitialMaxVersionRange() throws Exception {
  VersionRange expectedRange =
      VersionRange.createFromVersionSpec(
          String.format("[%s, %s)", majorVersion.getInitialVersion(), majorVersion.getMaxVersion()));
  assertEquals(
      "Major Versions should produce a version specification from "
          + "their initial version (inclusive) to their max version (exclusive)",
      expectedRange,
      majorVersion.getVersionRange());
}
 
Example 16
Source File: VersionRangeTest.java    From pom-manipulation-ext with Apache License 2.0 5 votes vote down vote up
@Test
public void testRange1() throws Exception
{
    String range = "1.0.0.Final";
    VersionRange s = VersionRange.createFromVersionSpec( range );

    assertFalse( s.hasRestrictions() );

    range = "[1.0.0.Final,)";
    s = VersionRange.createFromVersionSpec( range );
    assertTrue( s.hasRestrictions() );
}
 
Example 17
Source File: UseReleasesMojo.java    From versions-maven-plugin with Apache License 2.0 4 votes vote down vote up
private void useReleases( ModifiedPomXMLEventReader pom, MavenProject project )
    throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException
{
    String version = project.getVersion();
    Matcher versionMatcher = matchSnapshotRegex.matcher( version );
    if ( versionMatcher.matches() )
    {
        String releaseVersion = versionMatcher.group( 1 );

        VersionRange versionRange;
        try
        {
            versionRange = VersionRange.createFromVersionSpec( releaseVersion );
        }
        catch ( InvalidVersionSpecificationException e )
        {
            throw new MojoExecutionException( "Invalid version range specification: " + version, e );
        }

        Artifact artifact = artifactFactory.createDependencyArtifact( getProject().getParent().getGroupId(),
                                                                      getProject().getParent().getArtifactId(),
                                                                      versionRange, "pom", null, null );
        if ( !isIncluded( artifact ) )
        {
            return;
        }

        getLog().debug( "Looking for a release of " + toString( project ) );
        // Force releaseVersion version because org.apache.maven.artifact.metadata.MavenMetadataSource does not
        // retrieve release version if provided snapshot version.
        artifact.setVersion( releaseVersion );
        ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false );
        if ( !allowRangeMatching ) // standard behaviour
        {
            if ( versions.containsVersion( releaseVersion ) )
            {
                if ( PomHelper.setProjectParentVersion( pom, releaseVersion ) )
                {
                    getLog().info( "Updated " + toString( project ) + " to version " + releaseVersion );
                }
            }
            else if ( failIfNotReplaced )
            {
                throw new NoSuchElementException( "No matching release of " + toString( project )
                    + " found for update." );
            }
        }
        else
        {
            ArtifactVersion finalVersion = null;
            for ( ArtifactVersion proposedVersion : versions.getVersions( false ) )
            {
                if ( proposedVersion.toString().startsWith( releaseVersion ) )
                {
                    getLog().debug( "Found matching version for " + toString( project ) + " to version "
                        + releaseVersion );
                    finalVersion = proposedVersion;
                }
            }

            if ( finalVersion != null )
            {
                if ( PomHelper.setProjectParentVersion( pom, finalVersion.toString() ) )
                {
                    getLog().info( "Updated " + toString( project ) + " to version " + finalVersion.toString() );
                }
            }
            else
            {
                getLog().info( "No matching release of " + toString( project ) + " to update via rangeMatching." );
                if ( failIfNotReplaced )
                {
                    throw new NoSuchElementException( "No matching release of " + toString( project )
                        + " found for update via rangeMatching." );
                }
            }

        }
    }
}
 
Example 18
Source File: CassandraServer.java    From geowave with Apache License 2.0 4 votes vote down vote up
private StartGeoWaveStandalone(final int memory, final String directory) {
  super();
  startWaitSeconds = 180;
  rpcAddress = "127.0.0.1";
  rpcPort = 9160;
  jmxPort = 7199;
  startNativeTransport = true;
  nativeTransportPort = 9042;
  listenAddress = "127.0.0.1";
  storagePort = 7000;
  stopPort = 8081;
  stopKey = "cassandra-maven-plugin";
  maxMemory = memory;
  cassandraDir = new File(directory);
  logLevel = "ERROR";
  project = new MavenProject();
  project.setFile(cassandraDir);
  Field f;
  try {
    f = AbstractCassandraMojo.class.getDeclaredField("pluginArtifact");

    f.setAccessible(true);
    final DefaultArtifact a =
        new DefaultArtifact(
            "group",
            "artifact",
            VersionRange.createFromVersionSpec("version"),
            null,
            "type",
            null,
            new DefaultArtifactHandler());
    a.setFile(cassandraDir);
    f.set(this, a);

    f = AbstractCassandraMojo.class.getDeclaredField("pluginDependencies");
    f.setAccessible(true);
    f.set(this, new ArrayList<>());
  } catch (NoSuchFieldException | SecurityException | IllegalArgumentException
      | IllegalAccessException | InvalidVersionSpecificationException e) {
    LOGGER.error("Unable to initialize start cassandra cluster", e);
  }
}
 
Example 19
Source File: PluginBundleManager.java    From BIMserver with GNU Affero General Public License v3.0 4 votes vote down vote up
private void loadDependencies(String pluginBundleVersion, boolean strictDependencyChecking, Model model,
			DelegatingClassLoader delegatingClassLoader)
			throws DependencyCollectionException, InvalidVersionSpecificationException, Exception {
		if (model.getRepositories() != null) {
			for (Repository repository : model.getRepositories()) {
				mavenPluginRepository.addRepository(repository.getId(), "default", repository.getUrl());
			}
		}

		List<Dependency> dependenciesToResolve = new ArrayList<>();
		for (org.apache.maven.model.Dependency dependency2 : model.getDependencies()) {
			String scope = dependency2.getScope();
			if (scope != null && (scope.contentEquals("test"))) {
				// Skip
				continue;
			}
			Dependency d = new Dependency(new DefaultArtifact(dependency2.getGroupId(), dependency2.getArtifactId(), dependency2.getType(), dependency2.getVersion()), dependency2.getScope());
			Set<Exclusion> exclusions = new HashSet<>();
			d.setExclusions(exclusions);
			exclusions.add(new Exclusion("org.opensourcebim", "pluginbase", null, "jar"));
			exclusions.add(new Exclusion("org.opensourcebim", "shared", null, "jar"));
			exclusions.add(new Exclusion("org.opensourcebim", "ifcplugins", null, "jar"));
			dependenciesToResolve.add(d);
		}
		CollectRequest collectRequest = new CollectRequest(dependenciesToResolve, null, null);
		collectRequest.setRepositories(mavenPluginRepository.getRepositoriesAsList());
		CollectResult collectDependencies = mavenPluginRepository.getSystem().collectDependencies(mavenPluginRepository.getSession(), collectRequest);
		PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
		DependencyNode rootDep = collectDependencies.getRoot();
		rootDep.accept(nlg);
		
		for (Dependency dependency : nlg.getDependencies(true)) {
			if (dependency.getScope().contentEquals("test")) {
				continue;
			}
//			LOGGER.info(dependency.getArtifact().getGroupId() + "." + dependency.getArtifact().getArtifactId());
			Artifact dependencyArtifact = dependency.getArtifact();
			PluginBundleIdentifier pluginBundleIdentifier = new PluginBundleIdentifier(dependencyArtifact.getGroupId(), dependencyArtifact.getArtifactId());
			if (pluginBundleIdentifierToPluginBundle.containsKey(pluginBundleIdentifier)) {
				if (strictDependencyChecking) {
					String version = dependencyArtifact.getVersion();
					if (!version.contains("[") && !version.contains("(")) {
						version = "[" + version + "]";
					}
					VersionRange versionRange = VersionRange.createFromVersionSpec(version);
					// String version =
					// pluginBundleIdentifierToPluginBundle.get(pluginBundleIdentifier).getPluginBundleVersion().getVersion();
					ArtifactVersion artifactVersion = new DefaultArtifactVersion(pluginBundleVersion);
					if (versionRange.containsVersion(artifactVersion)) {
						// OK
					} else {
						throw new Exception(
								"Required dependency " + pluginBundleIdentifier + " is installed, but it's version (" + pluginBundleVersion + ") does not comply to the required version (" + dependencyArtifact.getVersion() + ")");
					}
				} else {
					LOGGER.info("Skipping strict dependency checking for dependency " + dependencyArtifact.getArtifactId());
				}
			} else {
				try {
					if (dependencyArtifact.getGroupId().contentEquals("com.sun.xml.ws")) {
						continue;
					}
					MavenPluginLocation mavenPluginLocation = mavenPluginRepository.getPluginLocation(dependencyArtifact.getGroupId(), dependencyArtifact.getArtifactId());
					if (dependencyArtifact.getExtension().contentEquals("jar")) {
						Path depJarFile = mavenPluginLocation.getVersionJar(dependencyArtifact.getVersion());
						
						FileJarClassLoader jarClassLoader = new FileJarClassLoader(pluginManager, delegatingClassLoader, depJarFile);
						jarClassLoaders.add(jarClassLoader);
						delegatingClassLoader.add(jarClassLoader);
					}
				} catch (Exception e) {
					e.printStackTrace();
					throw new Exception("Required dependency " + pluginBundleIdentifier + " is not installed");
				}
			}
		}
	}
 
Example 20
Source File: MavenCommandLineExecutor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private File guessBestMaven(RunConfig clonedConfig, InputOutput ioput) {
    MavenProject mp = clonedConfig.getMavenProject();
    if (mp != null) {
        if (mp.getPrerequisites() != null) {
            Prerequisites pp = mp.getPrerequisites();
            String ver = pp.getMaven();
            if (ver != null) {
                return checkAvailability(ver, null, ioput);
            }
        }
        String value = PluginPropertyUtils.getPluginPropertyBuildable(clonedConfig.getMavenProject(), Constants.GROUP_APACHE_PLUGINS, "maven-enforcer-plugin", "enforce", new PluginPropertyUtils.ConfigurationBuilder<String>() {
            @Override
            public String build(Xpp3Dom configRoot, ExpressionEvaluator eval) {
                if(configRoot != null) {
                    Xpp3Dom rules = configRoot.getChild("rules");
                    if (rules != null) {
                        Xpp3Dom rmv = rules.getChild("requireMavenVersion");
                        if (rmv != null) {
                            Xpp3Dom v = rmv.getChild("version");
                            if (v != null) {
                                return v.getValue();
                            }
                        }
                    }
                }
                return null;
            }
        });
        if (value != null) {
            if (value.contains("[") || value.contains("(")) {
                try {
                    VersionRange vr = VersionRange.createFromVersionSpec(value);
                    return checkAvailability(null, vr, ioput);
                } catch (InvalidVersionSpecificationException ex) {
                    Exceptions.printStackTrace(ex);
                }
            } else {
                return checkAvailability(value, null, ioput);
            }
        }
    }
    return null;
}