当前位置: 首页>>代码示例>>Java>>正文


Java VersionRange.createFromVersion方法代码示例

本文整理汇总了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() );
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:26,代码来源:TestDependencyUtil.java

示例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();
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:18,代码来源:NativeRanlibMojoTest.java

示例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() );
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:20,代码来源:NativeInitializeMojoTest.java

示例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()] );
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:18,代码来源:UseLatestReleasesMojo.java

示例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()] );
}
 
开发者ID:petr-ujezdsky,项目名称:versions-maven-plugin-svn-clone,代码行数:19,代码来源:UseLatestReleasesMojo.java

示例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 );

}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:13,代码来源:TestDependencyUtil.java

示例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;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:13,代码来源:DependencyProjectStub.java

示例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);
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:8,代码来源:AbstractProjectStub.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:Maven2ServerEmbedderImpl.java

示例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;
}
 
开发者ID:mojohaus,项目名称:clirr-maven-plugin,代码行数:31,代码来源:AbstractClirrMojo.java

示例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() );

}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:35,代码来源:NativeLinkerMojoTest.java

示例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() );

}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:36,代码来源:NativeLinkerMojoTest.java

示例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 );
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:30,代码来源:DefaultVersionsHelper.java

示例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 );
}
 
开发者ID:mojohaus,项目名称:webstart,代码行数:36,代码来源:GeneratorTest.java

示例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() );

    }
 
开发者ID:mojohaus,项目名称:webstart,代码行数:40,代码来源:VersionXmlGeneratorTest.java


注:本文中的org.apache.maven.artifact.versioning.VersionRange.createFromVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。