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);
}
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)));
});
}
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));
}
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;
}
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();
}
Aggregations