Search in sources :

Example 11 with DefaultArtifactVersion

use of org.apache.maven.artifact.versioning.DefaultArtifactVersion in project spring-boot by spring-projects.

the class LeadingZeroesDependencyVersion method parse.

static LeadingZeroesDependencyVersion parse(String input) {
    Matcher matcher = PATTERN.matcher(input);
    if (!matcher.matches()) {
        return null;
    }
    ArtifactVersion artifactVersion = new DefaultArtifactVersion(matcher.group(1) + matcher.group(2) + matcher.group(3));
    return new LeadingZeroesDependencyVersion(artifactVersion, input);
}
Also used : DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion) ArtifactVersion(org.apache.maven.artifact.versioning.ArtifactVersion) Matcher(java.util.regex.Matcher) DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion)

Example 12 with DefaultArtifactVersion

use of org.apache.maven.artifact.versioning.DefaultArtifactVersion in project MinecraftForge by MinecraftForge.

the class LanguageLoadingProvider method loadLanguageProviders.

private void loadLanguageProviders() {
    LOGGER.debug(CORE, "Found {} language providers", ServiceLoaderUtils.streamServiceLoader(() -> serviceLoader, sce -> LOGGER.fatal("Problem with language loaders")).count());
    serviceLoader.forEach(languageProviders::add);
    languageProviders.forEach(lp -> {
        final Path lpPath;
        try {
            lpPath = Paths.get(lp.getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
        } catch (URISyntaxException e) {
            throw new RuntimeException("Huh?", e);
        }
        Optional<String> implementationVersion = JarVersionLookupHandler.getImplementationVersion(lp.getClass());
        String impl = implementationVersion.orElse(Files.isDirectory(lpPath) ? FMLLoader.versionInfo().forgeVersion().split("\\.")[0] : null);
        if (impl == null) {
            LOGGER.fatal(CORE, "Found unversioned language provider {}", lp.name());
            throw new RuntimeException("Failed to find implementation version for language provider " + lp.name());
        }
        LOGGER.debug(CORE, "Found language provider {}, version {}", lp.name(), impl);
        StartupMessageManager.modLoaderConsumer().ifPresent(c -> c.accept("Loaded language provider " + lp.name() + " " + impl));
        languageProviderMap.put(lp.name(), new ModLanguageWrapper(lp, new DefaultArtifactVersion(impl)));
    });
}
Also used : Path(java.nio.file.Path) DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion) URISyntaxException(java.net.URISyntaxException)

Example 13 with DefaultArtifactVersion

use of org.apache.maven.artifact.versioning.DefaultArtifactVersion in project deltaspike by apache.

the class CdiContainerUnderTest method isCdiVersion.

/**
 * 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));
}
Also used : DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion) VersionRange(org.apache.maven.artifact.versioning.VersionRange)

Example 14 with DefaultArtifactVersion

use of org.apache.maven.artifact.versioning.DefaultArtifactVersion in project semantic-versioning by jeluard.

the class AbstractEnforcerRule method getAvailableReleasedVersions.

/**
 * @param artifactMetadataSource
 * @param project
 * @param localRepository
 * @return all available versions from most recent to oldest
 * @throws ArtifactMetadataRetrievalException
 */
protected final List<ArtifactVersion> getAvailableReleasedVersions(final ArtifactMetadataSource artifactMetadataSource, final MavenProject project, final ArtifactRepository localRepository) throws ArtifactMetadataRetrievalException {
    final List<ArtifactVersion> availableVersions = artifactMetadataSource.retrieveAvailableVersions(project.getArtifact(), localRepository, project.getRemoteArtifactRepositories());
    availableVersions.remove(new DefaultArtifactVersion(project.getArtifact().getVersion()));
    for (final Iterator<ArtifactVersion> iterator = availableVersions.iterator(); iterator.hasNext(); ) {
        final ArtifactVersion artifactVersion = iterator.next();
        if (Version.parse(artifactVersion.toString()).isSnapshot()) {
            iterator.remove();
        }
    }
    // TODO proper sorting based on Version
    Collections.sort(availableVersions);
    Collections.reverse(availableVersions);
    return availableVersions;
}
Also used : DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion) ArtifactVersion(org.apache.maven.artifact.versioning.ArtifactVersion) DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion)

Example 15 with DefaultArtifactVersion

use of org.apache.maven.artifact.versioning.DefaultArtifactVersion in project batfish by batfish.

the class Version method isCompatibleVersion.

// Visible for testing.
static boolean isCompatibleVersion(String myName, String myVersion, String otherName, @Nullable String otherVersion) {
    otherVersion = firstNonNull(otherVersion, UNKNOWN_VERSION);
    if (otherVersion.equals(INCOMPATIBLE_VERSION) || myVersion.equals(INCOMPATIBLE_VERSION)) {
        return false;
    }
    if (otherVersion.equals(UNKNOWN_VERSION) || myVersion.equals(UNKNOWN_VERSION)) {
        // Either version is unknown, assume compatible.
        return true;
    }
    DefaultArtifactVersion myArtifactVersion = parseVersion(myVersion, myName);
    DefaultArtifactVersion otherArtifactVersion = parseVersion(otherVersion, otherName);
    return myArtifactVersion.getMajorVersion() == otherArtifactVersion.getMajorVersion() && myArtifactVersion.getMinorVersion() == otherArtifactVersion.getMinorVersion();
}
Also used : DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion)

Aggregations

DefaultArtifactVersion (org.apache.maven.artifact.versioning.DefaultArtifactVersion)37 ArtifactVersion (org.apache.maven.artifact.versioning.ArtifactVersion)12 File (java.io.File)8 IOException (java.io.IOException)7 Model (org.apache.maven.model.Model)5 FileNotFoundException (java.io.FileNotFoundException)4 MavenXpp3Reader (org.apache.maven.model.io.xpp3.MavenXpp3Reader)4 ArrayList (java.util.ArrayList)3 Matcher (java.util.regex.Matcher)3 Artifact (org.apache.maven.artifact.Artifact)3 SPluginBundle (org.bimserver.interfaces.objects.SPluginBundle)3 SPluginBundleVersion (org.bimserver.interfaces.objects.SPluginBundleVersion)3 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)3 ArtifactDescriptorException (org.eclipse.aether.resolution.ArtifactDescriptorException)3 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)3 FileReader (java.io.FileReader)2 InputStream (java.io.InputStream)2 Path (java.nio.file.Path)2 HashMap (java.util.HashMap)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2