本文整理汇总了Java中org.apache.maven.artifact.versioning.InvalidVersionSpecificationException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidVersionSpecificationException类的具体用法?Java InvalidVersionSpecificationException怎么用?Java InvalidVersionSpecificationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvalidVersionSpecificationException类属于org.apache.maven.artifact.versioning包,在下文中一共展示了InvalidVersionSpecificationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataflowVersionRange
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的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.InvalidVersionSpecificationException; //导入依赖的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.InvalidVersionSpecificationException; //导入依赖的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.InvalidVersionSpecificationException; //导入依赖的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: isVersionOverlap
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的package包/类
/**
* Checks if two versions or ranges have an overlap.
*
* @param leftVersionOrRange the 1st version number or range to test
* @param rightVersionOrRange the 2nd version number or range to test
* @return true if both versions have an overlap
* @throws InvalidVersionSpecificationException if the versions can't be parsed to a range
*/
public static boolean isVersionOverlap( String leftVersionOrRange, String rightVersionOrRange )
throws InvalidVersionSpecificationException
{
VersionRange pomVersionRange = createVersionRange( leftVersionOrRange );
if ( !pomVersionRange.hasRestrictions() )
{
return true;
}
VersionRange oldVersionRange = createVersionRange( rightVersionOrRange );
if ( !oldVersionRange.hasRestrictions() )
{
return true;
}
VersionRange result = oldVersionRange.restrict( pomVersionRange );
return result.hasRestrictions();
}
示例6: toArtifact
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的package包/类
/**
* Try to find the dependency artifact that matches the given dependency.
*
* @param dependency
* @return
* @since 1.0-alpha-3
*/
protected Artifact toArtifact( Dependency dependency )
throws MojoExecutionException
{
Artifact artifact = findArtifact( dependency );
if ( artifact == null )
{
try
{
return getHelper().createDependencyArtifact( dependency );
}
catch ( InvalidVersionSpecificationException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
}
return artifact;
}
示例7: lookupDependenciesUpdates
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Map<Dependency, ArtifactVersions> lookupDependenciesUpdates( Set dependencies,
boolean usePluginRepositories )
throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException
{
Map<Dependency, ArtifactVersions> dependencyUpdates =
new TreeMap<Dependency, ArtifactVersions>( new DependencyComparator() );
for ( Object dependency1 : dependencies )
{
Dependency dependency = (Dependency) dependency1;
ArtifactVersions details = lookupDependencyUpdates( dependency, usePluginRepositories );
dependencyUpdates.put( dependency, details );
}
return dependencyUpdates;
}
示例8: isVersionOverlap
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的package包/类
/**
* Checks if two versions or ranges have an overlap.
*
* @param leftVersionOrRange the 1st version number or range to test
* @param rightVersionOrRange the 2nd version number or range to test
* @return true if both versions have an overlap
* @throws InvalidVersionSpecificationException
* if the versions can't be parsed to a range
*/
public static boolean isVersionOverlap( String leftVersionOrRange, String rightVersionOrRange )
throws InvalidVersionSpecificationException
{
VersionRange pomVersionRange = createVersionRange( leftVersionOrRange );
if ( !pomVersionRange.hasRestrictions() )
{
return true;
}
VersionRange oldVersionRange = createVersionRange( rightVersionOrRange );
if ( !oldVersionRange.hasRestrictions() )
{
return true;
}
VersionRange result = oldVersionRange.restrict( pomVersionRange );
return result.hasRestrictions();
}
示例9: getArtifact
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的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;
}
示例10: createPluginArtifact
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的package包/类
public Artifact createPluginArtifact( Plugin plugin )
{
VersionRange versionRange;
try
{
String version = plugin.getVersion();
if ( StringUtils.isEmpty( version ) )
{
version = "RELEASE";
}
versionRange = VersionRange.createFromVersionSpec( version );
}
catch ( InvalidVersionSpecificationException e )
{
return null;
}
return artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange );
}
示例11: disabledtestCircularDependencyNotIncludingCurrentProject
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的package包/类
public void disabledtestCircularDependencyNotIncludingCurrentProject()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
ArtifactSpec a = createArtifactSpec( "a", "1.0" );
ArtifactSpec b = a.addDependency( "b", "1.0" );
b.addDependency( "a", "1.0" );
try
{
collect( a );
fail( "Should have failed on cyclic dependency not involving project" );
}
catch ( CyclicDependencyException expected )
{
assertTrue( true );
}
}
示例12: disabledtestCircularDependencyIncludingCurrentProject
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的package包/类
public void disabledtestCircularDependencyIncludingCurrentProject()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
ArtifactSpec a = createArtifactSpec( "a", "1.0" );
ArtifactSpec b = a.addDependency( "b", "1.0" );
b.addDependency( "project", "1.0" );
try
{
collect( a );
fail( "Should have failed on cyclic dependency involving project" );
}
catch ( CyclicDependencyException expected )
{
assertTrue( true );
}
}
示例13: testResolveWithFilter
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的package包/类
public void testResolveWithFilter()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
ArtifactSpec a = createArtifactSpec( "a", "1.0" );
ArtifactSpec b = a.addDependency( "b", "1.0" );
ArtifactSpec c = a.addDependency( "c", "3.0" );
b.addDependency( "c", "2.0" );
ArtifactSpec d = b.addDependency( "d", "4.0" );
ArtifactResolutionResult res = collect( a );
assertEquals( "Check artifact list",
createSet( new Object[] { a.artifact, b.artifact, c.artifact, d.artifact } ), res.getArtifacts() );
ArtifactFilter filter = new ExclusionSetFilter( new String[] { "b" } );
res = collect( a, filter );
assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, c.artifact } ), res.getArtifacts() );
}
示例14: testResolveCorrectDependenciesWhenDifferentDependenciesOnNearest
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的package包/类
public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNearest()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
ArtifactSpec a = createArtifactSpec( "a", "1.0" );
ArtifactSpec b = a.addDependency( "b", "1.0" );
ArtifactSpec c2 = b.addDependency( "c", "2.0" );
c2.addDependency( "d", "1.0" );
ArtifactSpec e = createArtifactSpec( "e", "1.0" );
ArtifactSpec c1 = e.addDependency( "c", "1.0" );
ArtifactSpec f = c1.addDependency( "f", "1.0" );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) );
assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c1.artifact,
f.artifact } ), res.getArtifacts() );
assertEquals( "Check version", "1.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
}
示例15: disabledtestResolveCorrectDependenciesWhenDifferentDependenciesOnNewest
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; //导入依赖的package包/类
public void disabledtestResolveCorrectDependenciesWhenDifferentDependenciesOnNewest()
throws ArtifactResolutionException, InvalidVersionSpecificationException
{
// TODO: use newest conflict resolver
ArtifactSpec a = createArtifactSpec( "a", "1.0" );
ArtifactSpec b = a.addDependency( "b", "1.0" );
ArtifactSpec c2 = b.addDependency( "c", "2.0" );
ArtifactSpec d = c2.addDependency( "d", "1.0" );
ArtifactSpec e = createArtifactSpec( "e", "1.0" );
ArtifactSpec c1 = e.addDependency( "c", "1.0" );
c1.addDependency( "f", "1.0" );
ArtifactResolutionResult res = collect( createSet( new Object[] { a.artifact, e.artifact } ) );
assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c2.artifact,
d.artifact } ), res.getArtifacts() );
assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() );
}