本文整理匯總了Java中org.apache.maven.artifact.versioning.VersionRange.createFromVersion方法的典型用法代碼示例。如果您正苦於以下問題:Java VersionRange.createFromVersion方法的具體用法?Java VersionRange.createFromVersion怎麽用?Java VersionRange.createFromVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.artifact.versioning.VersionRange
的用法示例。
在下文中一共展示了VersionRange.createFromVersion方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
protected void setUp()
throws Exception
{
super.setUp();
ArtifactHandler ah = new DefaultArtifactHandlerStub( "jar", null );
VersionRange vr = VersionRange.createFromVersion( "1.1" );
release = new DefaultArtifact( "test", "one", vr, Artifact.SCOPE_COMPILE, "jar", "sources", ah, false );
artifacts.add( release );
ah = new DefaultArtifactHandlerStub( "war", null );
vr = VersionRange.createFromVersion( "1.1-SNAPSHOT" );
snap = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "war", null, ah, false );
artifacts.add( snap );
ah = new DefaultArtifactHandlerStub( "war", null );
vr = VersionRange.createFromVersion( "1.1-SNAPSHOT" );
sources = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "sources", "sources", ah, false );
// pick random output location
Random a = new Random();
outputFolder = new File( "target/copy" + a.nextLong() + "/" );
outputFolder.delete();
assertFalse( outputFolder.exists() );
}
示例2: testMojoLookup
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
public void testMojoLookup()
throws Exception
{
File pluginXml = new File( getBasedir(), "src/test/resources/linker/plugin-config-ranlib.xml" );
NativeRanlibMojo mojo = (NativeRanlibMojo) lookupMojo( "ranlib", pluginXml );
assertNotNull( mojo );
// simulate artifact
ArtifactHandler artifactHandler = new DefaultArtifactHandler();
Artifact artifact =
new DefaultArtifact( "test", "test", VersionRange.createFromVersion( "1.0-SNAPSHOT" ), "compile", "exe",
null, artifactHandler );
mojo.getProject().setArtifact( artifact );
mojo.execute();
}
示例3: testMojoLookup
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
public void testMojoLookup()
throws Exception
{
File pluginXml = new File( getBasedir(), "src/test/resources/initialize/plugin-config.xml" );
NativeInitializeMojo mojo = (NativeInitializeMojo) lookupMojo( "initialize", pluginXml );
assertNotNull( mojo );
// simulate artifact
ArtifactHandler artifactHandler = new DefaultArtifactHandler();
Artifact artifact =
new DefaultArtifact( "test", "test", VersionRange.createFromVersion( "1.0-SNAPSHOT" ), "compile", "exe",
null, artifactHandler );
mojo.project.setArtifact( artifact );
mojo.setPluginContext( new HashMap() );
mojo.execute();
assertEquals( "someArtifactId", mojo.project.getBuild().getFinalName() );
}
示例4: filterVersionsWithIncludes
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
private ArtifactVersion[] filterVersionsWithIncludes( ArtifactVersion[] newer, Artifact artifact )
{
List<ArtifactVersion> filteredNewer = new ArrayList<>( newer.length );
for ( int j = 0; j < newer.length; j++ )
{
ArtifactVersion artifactVersion = newer[j];
Artifact artefactWithNewVersion =
new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
VersionRange.createFromVersion( artifactVersion.toString() ), artifact.getScope(),
artifact.getType(), null, new DefaultArtifactHandler(), false );
if ( isIncluded( artefactWithNewVersion ) )
{
filteredNewer.add( artifactVersion );
}
}
return filteredNewer.toArray( new ArtifactVersion[filteredNewer.size()] );
}
示例5: filterVersionsWithIncludes
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
private ArtifactVersion[] filterVersionsWithIncludes( ArtifactVersion[] newer, Artifact artifact )
{
List filteredNewer = new ArrayList( newer.length );
for ( int j = 0; j < newer.length; j++ )
{
ArtifactVersion artifactVersion = newer[j];
Artifact artefactWithNewVersion = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
VersionRange.createFromVersion(
artifactVersion.toString() ),
artifact.getScope(), artifact.getType(), null,
new DefaultArtifactHandler(), false );
if ( isIncluded( artefactWithNewVersion ) )
{
filteredNewer.add( artifactVersion );
}
}
return (ArtifactVersion[]) filteredNewer.toArray( new ArtifactVersion[filteredNewer.size()] );
}
示例6: testTestJar
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
public void testTestJar()
{
ArtifactHandler ah = new DefaultArtifactHandlerStub( "test-jar", null );
VersionRange vr = VersionRange.createFromVersion( "1.1-SNAPSHOT" );
Artifact artifact = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "test-jar", null, ah,
false );
String name = DependencyUtil.getFormattedFileName( artifact, false );
String expectedResult = "two-1.1-SNAPSHOT.jar";
assertEquals( expectedResult, name );
}
示例7: getArtifact
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
public Artifact getArtifact()
{
if ( artifact == null )
{
ArtifactHandler ah = new DefaultArtifactHandlerStub( "jar", null );
VersionRange vr = VersionRange.createFromVersion( "1.0" );
Artifact art = new DefaultArtifact( "group", "artifact", vr, Artifact.SCOPE_COMPILE, "jar", null, ah, false );
setArtifact( art );
}
return artifact;
}
示例8: SimpleArtifactStub
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
private SimpleArtifactStub(String groupId, String artifactId, String version, String packaging) {
setGroupId(groupId);
setArtifactId(artifactId);
setVersion(version);
setType(packaging);
versionRange = VersionRange.createFromVersion(version);
}
示例9: retrieveAvailableVersions
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
@NotNull
@Override
public List<String> retrieveAvailableVersions(@NotNull String groupId,
@NotNull String artifactId,
@NotNull List<MavenRemoteRepository> remoteRepositories)
throws RemoteException {
try {
Artifact artifact =
new DefaultArtifact(groupId, artifactId, VersionRange.createFromVersion(""), Artifact.SCOPE_COMPILE, "pom", null,
new DefaultArtifactHandler("pom"));
ArtifactRepositoryLayout repositoryLayout = getComponent(ArtifactRepositoryLayout.class);
List versions = getComponent(ArtifactMetadataSource.class).retrieveAvailableVersions(
artifact,
new DefaultArtifactRepository(
"local",
getLocalRepositoryFile().getPath(),
repositoryLayout),
convertRepositories(remoteRepositories));
List<String> result = new ArrayList<String>();
for (Object version : versions) {
result.add(version.toString());
}
return result;
}
catch (Exception e) {
Maven2ServerGlobals.getLogger().info(e);
}
return Collections.emptyList();
}
示例10: resolveArtifact
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
private Artifact resolveArtifact( ArtifactSpecification artifactSpec )
throws MojoFailureException, MojoExecutionException
{
final String groupId = artifactSpec.getGroupId();
if ( groupId == null )
{
throw new MojoFailureException( "An artifacts groupId is required." );
}
final String artifactId = artifactSpec.getArtifactId();
if ( artifactId == null )
{
throw new MojoFailureException( "An artifacts artifactId is required." );
}
final String version = artifactSpec.getVersion();
if ( version == null )
{
throw new MojoFailureException( "An artifacts version number is required." );
}
final VersionRange versionRange = VersionRange.createFromVersion( version );
String type = artifactSpec.getType();
if ( type == null )
{
type = "jar";
}
Artifact artifact =
factory.createDependencyArtifact( groupId, artifactId, versionRange, type, artifactSpec.getClassifier(),
Artifact.SCOPE_COMPILE );
return artifact;
}
示例11: testExecute
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
public void testExecute() throws Exception
{
NativeLinkMojo mojo = getMojo();
// simulate object files
List objectList = new ArrayList();
objectList.add( new File( "o1.o" ) );
objectList.add( new File( "o2.o" ) );
mojo.saveCompilerOutputFilePaths( objectList );
// simulate artifact
ArtifactHandler artifactHandler = new DefaultArtifactHandler();
Artifact artifact = new DefaultArtifact( "test", "test", VersionRange.createFromVersion( "1.0-SNAPSHOT" ), "compile", "exe", null, artifactHandler);
mojo.getProject().setArtifact( artifact );
// simulate artifacts
mojo.getProject().setArtifacts( new HashSet() ); // no extern libs for now
String linkerFinalName = "some-final-name";
setVariableValueToObject( mojo, "linkerFinalName", linkerFinalName );
mojo.execute();
LinkerConfiguration conf = mojo.getLgetLinkerConfiguration();
// "target is set in the stub
assertEquals( new File( "target" ), conf.getOutputDirectory() );
assertEquals( linkerFinalName, conf.getOutputFileName() );
assertNull(conf.getOutputFileExtension() );
// current artifactHandler mocking return null extension name
assertEquals( new File( "target/some-final-name.null" ), conf.getOutputFile() );
}
示例12: testExecuteWithFinalNameExtension
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
public void testExecuteWithFinalNameExtension() throws Exception
{
NativeLinkMojo mojo = getMojo();
// simulate object files
List objectList = new ArrayList();
objectList.add( new File( "o1.o" ) );
objectList.add( new File( "o2.o" ) );
mojo.saveCompilerOutputFilePaths( objectList );
// simulate artifact
ArtifactHandler artifactHandler = new DefaultArtifactHandler();
Artifact artifact = new DefaultArtifact( "test", "test", VersionRange.createFromVersion( "1.0-SNAPSHOT" ), "compile", "exe", null, artifactHandler );
mojo.getProject().setArtifact( artifact );
// simulate artifacts
mojo.getProject().setArtifacts( new HashSet() ); // no extern libs for now
String linkerFinalName = "some-final-name";
setVariableValueToObject( mojo, "linkerFinalName", linkerFinalName );
String linkerFinalNameExt = "some-extension";
setVariableValueToObject( mojo, "linkerFinalNameExt", linkerFinalNameExt );
mojo.execute();
LinkerConfiguration conf = mojo.getLgetLinkerConfiguration();
// "target is set in the stub
assertEquals( new File( "target" ), conf.getOutputDirectory() );
assertEquals( linkerFinalName, conf.getOutputFileName() );
assertEquals( linkerFinalNameExt, conf.getOutputFileExtension() );
assertEquals( new File( "target/some-final-name.some-extension" ), conf.getOutputFile() );
}
示例13: lookupPluginUpdates
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots )
throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException
{
String version = plugin.getVersion();
version = version == null ? "LATEST" : version;
getLog().debug( "Checking " + ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() )
+ " for updates newer than " + version );
VersionRange versionRange = VersionRange.createFromVersion( version );
final boolean includeSnapshots = allowSnapshots;
final ArtifactVersions pluginArtifactVersions =
lookupArtifactVersions( createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ),
true );
Set<Dependency> pluginDependencies = new TreeSet<Dependency>( new DependencyComparator() );
if ( plugin.getDependencies() != null )
{
pluginDependencies.addAll( plugin.getDependencies() );
}
Map<Dependency, ArtifactVersions> pluginDependencyDetails =
lookupDependenciesUpdates( pluginDependencies, false );
return new PluginUpdatesDetails( pluginArtifactVersions, pluginDependencyDetails, includeSnapshots );
}
示例14: setUp
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
@Override
public void setUp()
throws Exception
{
super.setUp();
DefaultArtifactHandler artifactHandler = new DefaultArtifactHandler( "jar" );
artifact1 =
new DefaultArtifact( "groupId", "artifact1", VersionRange.createFromVersion( "1.0" ), "scope", "jar",
"classifier", artifactHandler );
artifact1.setFile( new File( "artifact1-1.0.jar" ) );
artifact2 =
new DefaultArtifact( "groupId", "artifact2", VersionRange.createFromVersion( "1.5" ), null, "jar", "",
artifactHandler );
artifact2.setFile( new File( "artifact2-1.5.jar" ) );
// add a SNAPSHOT artifact, timestamped (from a remote maven repository)
artifact3 =
new DefaultArtifact( "groupId", "artifact3", VersionRange.createFromVersion( "1.5-SNAPSHOT" ), null, "jar", "",
artifactHandler );
artifact3.setVersion("1.5-15012014.121212-1");
artifact3.setFile( new File( "artifact3-1.5-15012014.121212-1.jar" ) );
// add a SNAPSHOT artifact, not timestamped (from a local build)
artifact4 =
new DefaultArtifact( "groupId", "artifact4", VersionRange.createFromVersion( "1.5-SNAPSHOT" ), null, "jar", "",
artifactHandler );
artifact4.setFile( new File( "artifact4-1.5-SNAPSHOT.jar" ) );
artifacts = new ArrayList<>();
artifacts.add( artifact1 );
artifacts.add( artifact2 );
artifacts.add( artifact3 );
artifacts.add( artifact4 );
}
示例15: testWithMultiJarResources
import org.apache.maven.artifact.versioning.VersionRange; //導入方法依賴的package包/類
public void testWithMultiJarResources()
throws IOException, SAXException, ParserConfigurationException, MojoExecutionException
{
Artifact artifact1 =
new DefaultArtifact( "groupId", "artifactId1", VersionRange.createFromVersion( "1.0" ), "scope", "jar",
"classifier", null );
artifact1.setFile( new File( "bogus1.txt" ) );
Artifact artifact2 =
new DefaultArtifact( "groupId", "artifactId2", VersionRange.createFromVersion( "1.0" ), "scope", "jar",
"classifier", null );
artifact2.setFile( new File( "bogus2.txt" ) );
ResolvedJarResource jar1 = new ResolvedJarResource( artifact1 );
ResolvedJarResource jar2 = new ResolvedJarResource( artifact2 );
// jar1.setArtifact( artifact1 );
// jar2.setArtifact( artifact2 );
List<ResolvedJarResource> jarResources = new ArrayList<>( 2 );
jarResources.add( jar1 );
jarResources.add( jar2 );
new VersionXmlGenerator( "utf-8" ).generate( this.outputDir, jarResources );
String actualXml = readFileContents( this.expectedFile );
String expected = "<?xml version=\"1.0\"?><jnlp-versions>" + " <resource>" + " <pattern>" + " <name>bogus1.txt</name>" +
" <version-id>1.0</version-id>" + " </pattern>" +
" <file>artifactId1-1.0-classifier.jar</file>" + " </resource>" + " <resource>" + " <pattern>" +
" <name>bogus2.txt</name>" + " <version-id>1.0</version-id>" +
" </pattern>" + " <file>artifactId2-1.0-classifier.jar</file>" + " </resource>" +
"</jnlp-versions>";
Assert.assertEquals( actualXml, expected );
Diff diff = new Diff( expected, actualXml );
Assert.assertTrue( diff.toString(), diff.similar() );
}