本文整理汇总了Java中org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec方法的典型用法代码示例。如果您正苦于以下问题:Java VersionRange.createFromVersionSpec方法的具体用法?Java VersionRange.createFromVersionSpec怎么用?Java VersionRange.createFromVersionSpec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.artifact.versioning.VersionRange
的用法示例。
在下文中一共展示了VersionRange.createFromVersionSpec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataflowVersionRange
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
public VersionRange getDataflowVersionRange(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 allVersions();
}
示例2: getArtifact
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
protected Artifact getArtifact(ArtifactItem artifactItem) throws MojoExecutionException, InvalidVersionSpecificationException {
Artifact artifact;
VersionRange vr = VersionRange.createFromVersionSpec(artifactItem.getVersion());
if (StringUtils.isEmpty(artifactItem.getClassifier())) {
artifact = factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr,
artifactItem.getType(), null, Artifact.SCOPE_COMPILE );
} else {
artifact = factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr,
artifactItem.getType(), artifactItem.getClassifier(),
Artifact.SCOPE_COMPILE );
}
try {
resolver.resolve(artifact, remoteRepos, local);
} catch (ArtifactResolutionException | ArtifactNotFoundException e) {
throw new MojoExecutionException("Error resolving artifact "+artifact, e);
}
return artifact;
}
示例3: createManagedVersionMap
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
/**
*
* @param projectId
* @param dependencyManagement
* @return
* @throws ProjectBuildingException
*/
private Map createManagedVersionMap(String projectId, DependencyManagement dependencyManagement) throws ProjectBuildingException {
Map 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.EMPTY_MAP;
}
return map;
}
示例4: getIvyVersionRange
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
protected final VersionRange getIvyVersionRange() throws MojoExecutionException
{
try
{
VersionRange ivyVersionRange = VersionRange.createFromVersionSpec(ivyVersion);
if (ivyVersionRange.getRecommendedVersion() != null)
{
ivyVersionRange = VersionRange.createFromVersionSpec("["+ivyVersion+"]");
}
if (restrictVersionToMinimalCompatible)
{
return restrictToMinimalCompatible(ivyVersionRange);
}
return ivyVersionRange;
}
catch (InvalidVersionSpecificationException ex)
{
throw new MojoExecutionException("Invalid ivyVersion '"+ivyVersion+"'.", ex);
}
}
示例5: testInitialMaxVersionRange
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
@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());
}
示例6: setup
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
latestVersion = new DefaultArtifactVersion("1.20.0-beta1");
currentVersionSpec = VersionRange.createFromVersionSpec("[1.2.3, 1.99.0)");
when(dependencyManager.getDataflowVersionRange(project)).thenReturn(currentVersionSpec);
when(dependencyManager.getLatestDataflowDependencyInRange(currentVersionSpec))
.thenReturn(latestVersion);
model = new DataflowMavenModel(dependencyManager, xpath, project, domModel);
when(domModel.getDocument()).thenReturn(document);
when(domModel.getUndoManager()).thenReturn(undoManager);
monitor = new NullProgressMonitor();
}
示例7: testGetGuava19
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
@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());
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:9,代码来源:ArtifactRetrieverIntegrationTest.java
示例8: allVersions
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
private 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);
}
}
示例9: restrictToMinimalCompatible
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
private VersionRange restrictToMinimalCompatible(VersionRange ivyVersionRange)
throws InvalidVersionSpecificationException, MojoExecutionException
{
VersionRange minimalCompatibleVersionRange = VersionRange.createFromVersionSpec("[" + AbstractEngineMojo.MINIMAL_COMPATIBLE_VERSION + ",)");
VersionRange restrictedIvyVersionRange = ivyVersionRange.restrict(minimalCompatibleVersionRange);
if (!restrictedIvyVersionRange.hasRestrictions())
{
throw new MojoExecutionException("The ivyVersion '"+ivyVersion+"' is lower than the minimal compatible version"
+ " '"+MINIMAL_COMPATIBLE_VERSION+"'.");
}
return restrictedIvyVersionRange;
}
示例10: ProxyArtifactStore
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
/**
* Creates a new instance.
*
* @param repositoryMetadataManager the {@link RepositoryMetadataManager} to use.
* @param remoteArtifactRepositories the repsoitories to use.
* @param remotePluginRepositories the plugin repositories to use.
* @param localRepository the local repository to use.
* @param artifactFactory the {@link ArtifactFactory} to use.
* @param artifactResolver the {@link ArtifactResolver} to use.
* @param log the {@link Log} to log to.
*/
public ProxyArtifactStore( RepositoryMetadataManager repositoryMetadataManager,
List<ArtifactRepository> remoteArtifactRepositories,
List<ArtifactRepository> remotePluginRepositories, ArtifactRepository localRepository,
ArtifactFactory artifactFactory, ArtifactResolver artifactResolver, ArchetypeManager archetypeManager, Log log )
{
this.repositoryMetadataManager = repositoryMetadataManager;
this.remotePluginRepositories = remotePluginRepositories;
this.localRepository = localRepository;
this.artifactFactory = artifactFactory;
this.artifactResolver = artifactResolver;
this.archetypeManager = archetypeManager;
this.log = log;
remoteRepositories = new ArrayList<ArtifactRepository>();
remoteRepositories.addAll( remoteArtifactRepositories );
remoteRepositories.addAll( remotePluginRepositories );
try
{
anyVersion = VersionRange.createFromVersionSpec( "[0,]" );
}
catch ( InvalidVersionSpecificationException e )
{
// must never happen... so if it does make sure we stop
IllegalStateException ise =
new IllegalStateException( "[0,] should always be a valid version specification" );
ise.initCause( e );
throw ise;
}
}
示例11: lookupDependencyUpdates
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
/**
* {@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 );
}
示例12: createVersionRange
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
private static VersionRange createVersionRange( String versionOrRange )
throws InvalidVersionSpecificationException
{
VersionRange versionRange = VersionRange.createFromVersionSpec( versionOrRange );
if ( versionRange.getRecommendedVersion() != null )
{
versionRange = VersionRange.createFromVersionSpec( "[" + versionOrRange + "]" );
}
return versionRange;
}
示例13: getVersionsInRange
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
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;
}
示例14: testSmokes
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
public void testSmokes()
throws Exception
{
ArtifactVersion[] versions =
new ArtifactVersion[]{new DefaultArtifactVersion( "1.0" ), new DefaultArtifactVersion( "3.0" ),
new DefaultArtifactVersion( "1.1" ), new DefaultArtifactVersion( "1.0" ),
new DefaultArtifactVersion( "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() );
System.out.println( Arrays.asList( instance.getVersions() ) );
assertArrayEquals(
new ArtifactVersion[]{new DefaultArtifactVersion( "1.0" ), new DefaultArtifactVersion( "1.0.1" ),
new DefaultArtifactVersion( "1.1" ), new DefaultArtifactVersion( "3.0" ),}, instance.getVersions() );
assertArrayEquals( new ArtifactVersion[]{new DefaultArtifactVersion( "3.0" ),},
instance.getVersions( new DefaultArtifactVersion( "1.1" ), null ) );
assertArrayEquals(
new ArtifactVersion[]{new DefaultArtifactVersion( "1.1" ), new DefaultArtifactVersion( "3.0" ),},
instance.getVersions( new DefaultArtifactVersion( "1.0.1" ), null ) );
assertEquals( new DefaultArtifactVersion( "1.1" ).toString(),
instance.getNewestVersion( new DefaultArtifactVersion( "1.0" ),
new DefaultArtifactVersion( "3.0" ) ).toString() );
assertNull(
instance.getNewestVersion( new DefaultArtifactVersion( "1.1" ), new DefaultArtifactVersion( "3.0" ) ) );
}
示例15: lookupDependencyUpdates
import org.apache.maven.artifact.versioning.VersionRange; //导入方法依赖的package包/类
/**
* {@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 );
}