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


Java MavenArtifactRepository类代码示例

本文整理汇总了Java中org.apache.maven.artifact.repository.MavenArtifactRepository的典型用法代码示例。如果您正苦于以下问题:Java MavenArtifactRepository类的具体用法?Java MavenArtifactRepository怎么用?Java MavenArtifactRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MavenArtifactRepository类属于org.apache.maven.artifact.repository包,在下文中一共展示了MavenArtifactRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addBndSnapshotRepo

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
private void addBndSnapshotRepo(MavenProject project) {

		ArtifactRepository ar = new MavenArtifactRepository();
		ar.setId("bnd-snapshots");
		ar.setUrl("https://bndtools.ci.cloudbees.com/job/bnd.master/lastSuccessfulBuild/artifact/dist/bundles/");
		ar.setLayout(defaultLayout);

		List<ArtifactRepository> pluginRepos = new LinkedList<>();
		pluginRepos.addAll(project.getPluginArtifactRepositories());
		pluginRepos.add(ar);
		project.setPluginArtifactRepositories(pluginRepos);

		List<ArtifactRepository> repos = new LinkedList<>();
		repos.addAll(project.getRemoteArtifactRepositories());
		repos.add(ar);
		project.setRemoteArtifactRepositories(repos);

	}
 
开发者ID:commsen,项目名称:EM,代码行数:19,代码来源:EccentricModularityExecutionListener.java

示例2: testFindArtifactInRepository

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
@Test
public void testFindArtifactInRepository() throws MojoExecutionException {
    GenerateMojo mojo = new GenerateMojo();
    mojo.setLog(new SystemStreamLog());

    Dependency dependency = mojo.findArtifactInRepository(
            new DefaultArtifact("org.spigotmc", "spigot-api", "1.8-R0.1-SNAPSHOT",
                                "compile", "jar", "jar", new DefaultArtifactHandler()),
            new MavenArtifactRepository("yawkat",
                                        "http://mvn.yawk.at",
                                        new DefaultRepositoryLayout(),
                                        new ArtifactRepositoryPolicy(),
                                        new ArtifactRepositoryPolicy())
    );
    Assert.assertNotNull(dependency);
}
 
开发者ID:yawkat,项目名称:mdep,代码行数:17,代码来源:GenerateMojoTest.java

示例3: convertFromMavenSettingsRepository

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
public static ArtifactRepository convertFromMavenSettingsRepository(Repository repository)
{
   MavenArtifactRepository result = new MavenArtifactRepository();
   result.setId(repository.getId());
   result.setUrl(repository.getUrl());

   String layout = repository.getLayout();
   if ("default".equals(layout))
      result.setLayout(new DefaultRepositoryLayout());
   else if ("p2".equals(layout))
      result.setLayout(new P2ArtifactRepositoryLayout());

   RepositoryPolicy releases = repository.getReleases();
   if (releases != null)
      result.setReleaseUpdatePolicy(new ArtifactRepositoryPolicy(releases.isEnabled(), releases.getUpdatePolicy(),
               releases.getChecksumPolicy()));

   RepositoryPolicy snapshots = repository.getSnapshots();
   if (snapshots != null)
      result.setSnapshotUpdatePolicy(new ArtifactRepositoryPolicy(snapshots.isEnabled(),
               snapshots.getUpdatePolicy(),
               snapshots.getChecksumPolicy()));

   return result;
}
 
开发者ID:forge,项目名称:furnace,代码行数:26,代码来源:RepositoryUtils.java

示例4: toArtifactRepository

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
public static ArtifactRepository toArtifactRepository(String id, String url, String layout,
         boolean containsReleases,
         boolean containsSnapshots)
{
   MavenArtifactRepository result = new MavenArtifactRepository();
   result.setId(id);
   result.setUrl(url);

   if (layout == null || layout.isEmpty() || "default".equals(layout))
   {
      result.setLayout(new DefaultRepositoryLayout());
   }
   else if ("p2".equals(layout))
   {
      result.setLayout(new P2ArtifactRepositoryLayout());
   }
   result.setReleaseUpdatePolicy(new ArtifactRepositoryPolicy(containsReleases,
            ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER,
            ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN));
   result.setSnapshotUpdatePolicy(new ArtifactRepositoryPolicy(containsSnapshots,
            ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY,
            ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN));
   return result;

}
 
开发者ID:forge,项目名称:furnace,代码行数:26,代码来源:RepositoryUtils.java

示例5: propagateRepositoryPolicies

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
@Test
// SWARM-1173: swarm-plugin trying to download SNAPSHOTs from Maven Central
public void propagateRepositoryPolicies() {
    RepositorySystemSession sessionMock = Mockito.mock(RepositorySystemSession.class);
    MirrorSelector mirrorSelectorMock = Mockito.mock(MirrorSelector.class);
    Mockito.when(sessionMock.getMirrorSelector()).thenReturn(mirrorSelectorMock);
    ProxySelector proxySelectorMock = Mockito.mock(ProxySelector.class);
    Mockito.when(sessionMock.getProxySelector()).thenReturn(proxySelectorMock);

    MavenArtifactResolvingHelper artifactResolverHelper = new MavenArtifactResolvingHelper(null, null, sessionMock, null);
    ArtifactRepositoryPolicy testSnapshotPolicy = new ArtifactRepositoryPolicy(false, "hourly", "warn");
    ArtifactRepositoryPolicy testReleasesPolicy = new ArtifactRepositoryPolicy(true, "never", "warn");
    ArtifactRepository testingRepo = new MavenArtifactRepository("testing-repo", "http://testing-repo.org", new DefaultRepositoryLayout(), testSnapshotPolicy, testReleasesPolicy);
    artifactResolverHelper.remoteRepository(testingRepo);

    List<RemoteRepository> remoteRepos = artifactResolverHelper.getRemoteRepositories();

    Assert.assertTrue("Remote repositories " + remoteRepos + " do not contain expected testing repo " + testingRepo,
                      remoteRepos.stream().anyMatch(
                              remoteRepo -> {
                                  RepositoryPolicy snapshotsPolicy = remoteRepo.getPolicy(true);
                                  RepositoryPolicy releasesPolicy = remoteRepo.getPolicy(false);
                                  return remoteRepo.getId().equals(testingRepo.getId()) &&
                                          !snapshotsPolicy.isEnabled() &&
                                          snapshotsPolicy.getUpdatePolicy().equals(testSnapshotPolicy.getUpdatePolicy()) &&
                                          snapshotsPolicy.getChecksumPolicy().equals(testSnapshotPolicy.getChecksumPolicy()) &&
                                          releasesPolicy.isEnabled() &&
                                          releasesPolicy.getUpdatePolicy().equals(testReleasesPolicy.getUpdatePolicy()) &&
                                          releasesPolicy.getChecksumPolicy().equals(testReleasesPolicy.getChecksumPolicy());
                              })
    );
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:33,代码来源:MavenArtifactResolvingHelperTest.java

示例6: repo

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
private ArtifactRepository repo(String id, String url, boolean releases,
		boolean snapshots) {
	MavenArtifactRepository repository = new MavenArtifactRepository();
	repository.setLayout(new DefaultRepositoryLayout());
	repository.setId(id);
	repository.setUrl(url);
	ArtifactRepositoryPolicy enabled = new ArtifactRepositoryPolicy();
	enabled.setEnabled(true);
	ArtifactRepositoryPolicy disabled = new ArtifactRepositoryPolicy();
	disabled.setEnabled(false);
	repository.setReleaseUpdatePolicy(releases ? enabled : disabled);
	repository.setSnapshotUpdatePolicy(snapshots ? enabled : disabled);
	return repository;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-function,代码行数:15,代码来源:DependencyResolver.java

示例7: testCreateEffectivePom

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
/**
 * Tests method to create effective POM.
 *
 * @throws Exception if something goes wrong.
 */
@Test
public void testCreateEffectivePom()
    throws Exception
{

    String magicValue = "magic-value";
    Properties userProperties = new Properties();
    userProperties.setProperty( "cmd.test.property", magicValue );

    File pomFile = new File( "src/test/resources/cmdpropertysubstituion/pom.xml" );
    ArtifactRepository localRepository = new MavenArtifactRepository();
    localRepository.setLayout( new DefaultRepositoryLayout() );
    ArtifactFactory artifactFactory = new DefaultArtifactFactory();
    ArtifactHandlerManager artifactHandlerManager = new DefaultArtifactHandlerManager();
    setDeclaredField( artifactFactory, "artifactHandlerManager", artifactHandlerManager );
    Map<String, ArtifactHandler> artifactHandlers = new HashMap<String, ArtifactHandler>();
    setDeclaredField( artifactHandlerManager, "artifactHandlers", artifactHandlers );
    DefaultDependencyResolver depencencyResolver = new DefaultDependencyResolver();
    DefaultProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest();
    FlattenModelResolver resolver = new FlattenModelResolver( localRepository, artifactFactory,
            depencencyResolver, projectBuildingRequest, Collections.<MavenProject>emptyList() );
    ModelBuildingRequest buildingRequest =
        new DefaultModelBuildingRequest().setPomFile( pomFile ).setModelResolver( resolver ).setUserProperties( userProperties );
    Model effectivePom = FlattenMojo.createEffectivePom( buildingRequest, false );
    assertThat( effectivePom.getName() ).isEqualTo( magicValue );
}
 
开发者ID:mojohaus,项目名称:flatten-maven-plugin,代码行数:32,代码来源:CreateEffectivePomTest.java

示例8: setupSession

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
private VersioningState setupSession( final Properties properties, final Map<ProjectRef, String[]> versionMap )
    throws Exception
{
    final ArtifactRepository ar =
        new MavenArtifactRepository( "test", "http://repo.maven.apache.org/maven2", new DefaultRepositoryLayout(),
                                     new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() );

    final MavenExecutionRequest req =
        new DefaultMavenExecutionRequest().setUserProperties( properties )
                                          .setRemoteRepositories( Arrays.asList( ar ) );

    final PlexusContainer container = new DefaultPlexusContainer();

    final MavenSession mavenSession = new MavenSession( container, null, req, new DefaultMavenExecutionResult() );

    session = new ManipulationSession();
    session.setMavenSession( mavenSession );

    final VersioningState state = new VersioningState( properties );
    session.setState( state );

    final Map<String, byte[]> dataMap = new HashMap<>();
    if ( versionMap != null && !versionMap.isEmpty() )
    {
        for ( final Map.Entry<ProjectRef, String[]> entry : versionMap.entrySet() )
        {
            final String path = toMetadataPath( entry.getKey() );
            final byte[] data = setupMetadataVersions( entry.getValue() );
            dataMap.put( path, data );
        }
    }

    final Location mdLoc = MavenLocationExpander.EXPANSION_TARGET;
    final Transport mdTrans = new StubTransport( dataMap );

    modder =
        new TestVersionCalculator( new ManipulationSession(), mdLoc, mdTrans, temp.newFolder( "galley-cache" ) );

    return state;
}
 
开发者ID:release-engineering,项目名称:pom-manipulation-ext,代码行数:41,代码来源:VersioningCalculatorTest.java

示例9: createArtifactRepository

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
public ArtifactRepository createArtifactRepository( String id, String url,
                                                    ArtifactRepositoryLayout repositoryLayout,
                                                    ArtifactRepositoryPolicy snapshots,
                                                    ArtifactRepositoryPolicy releases )
{
    return new MavenArtifactRepository( id, url, repositoryLayout, snapshots, releases );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:8,代码来源:TestRepositorySystem.java

示例10: createDefaultRemoteRepository

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
public ArtifactRepository createDefaultRemoteRepository()
    throws InvalidRepositoryException
{
    return new MavenArtifactRepository( DEFAULT_REMOTE_REPO_ID, "file://"
        + new File( System.getProperty( "basedir", "" ), "src/test/remote-repo" ).toURI().getPath(),
                                        new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(),
                                        new ArtifactRepositoryPolicy() );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:9,代码来源:TestRepositorySystem.java

示例11: createLocalRepository

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
public ArtifactRepository createLocalRepository( File localRepository )
    throws InvalidRepositoryException
{
    return new MavenArtifactRepository( DEFAULT_LOCAL_REPO_ID, "file://" + localRepository.toURI().getPath(),
                                        new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(),
                                        new ArtifactRepositoryPolicy() );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:8,代码来源:TestRepositorySystem.java

示例12: lookupConfiguredMojo

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
public E lookupConfiguredMojo(File pom, String goal, TestDB testDb) throws Exception {

		// Mojoテストリソースディレクトリのパスをシステムプロパティに設定しておく
//		System.setProperty("MojoTestRoot", getMojoTestRoot());

		// 各DBの接続情報をシステムプロパティへマージする
		Properties prop = new Properties();
		prop.load(new FileInputStream(new File(Thread.currentThread().getContextClassLoader().getResource("jdbc_test.properties").getPath())));
		System.getProperties().putAll(prop);

		// Maven実行リクエスト初期化
		MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();

		// テスト用のsettingファイルで初期化
//		File settings = new File(this.getClass().getResource("settings.xml").getPath());
		File settings = new File(Thread.currentThread().getContextClassLoader().getResource("settings.xml").getPath());
		MavenExecutionRequestPopulator populator = getContainer().lookup(MavenExecutionRequestPopulator.class);
		MavenSettingsBuilder mb = this.lookup(MavenSettingsBuilder.class);
		Settings st = mb.buildSettings(settings);
		populator.populateFromSettings(executionRequest, st);

		// カレントディレクトリをセット
		executionRequest.setBaseDirectory(pom.getParentFile());

		// プロファイルを指定DBのプロファイルにセット
		executionRequest.setActiveProfiles(Collections.singletonList(testDb.name()));

		// ローカルリポジトリオブジェクトのセット
		String localRepoPath = this.getClass().getResource("testLocalRepo").toURI().toURL().toString();
		executionRequest.setLocalRepository(new MavenArtifactRepository(RepositorySystem.DEFAULT_LOCAL_REPO_ID,
				localRepoPath, new DefaultRepositoryLayout(),
				new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy()));

		// 実行プロジェクトを作成
		ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest();
		DefaultMaven maven = (DefaultMaven) getContainer().lookup(Maven.class);
		DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) maven
				.newRepositorySession(executionRequest);
		repoSession.setOffline(true);
		buildingRequest.setRepositorySession(repoSession);
		ProjectBuilder projectBuilder = this.lookup(ProjectBuilder.class);
		MavenProject project = projectBuilder.build(pom, buildingRequest).getProject();

		currentMavenExecutionRequest = executionRequest;

		// 指定ゴールを持つMojoを取得
		Mojo mojo = this.lookupConfiguredMojo(project, goal);

		currentProject = project;
		return (E) mojo;
	}
 
开发者ID:coastland,项目名称:gsp-dba-maven-plugin,代码行数:52,代码来源:AbstractDdlMojoTest.java

示例13: addSettingsProfileRepositoriesTo

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
private void addSettingsProfileRepositoriesTo( final Set<Location> locs, final Settings settings,
                                               final List<String> activeProfiles,
                                               final MirrorSelector mirrorSelector )
    throws MalformedURLException
{
    if ( settings != null )
    {
        final Map<String, Profile> profiles = settings.getProfilesAsMap();
        if ( profiles != null && activeProfiles != null && !activeProfiles.isEmpty() )
        {
            final LinkedHashSet<String> active = new LinkedHashSet<>( activeProfiles );

            final List<String> settingsActiveProfiles = settings.getActiveProfiles();
            if ( settingsActiveProfiles != null && !settingsActiveProfiles.isEmpty() )
            {
                active.addAll( settingsActiveProfiles );
            }

            for ( final String profileId : active )
            {
                final Profile profile = profiles.get( profileId );
                if ( profile != null )
                {
                    final List<Repository> repositories = profile.getRepositories();
                    if ( repositories != null )
                    {
                        final List<Mirror> mirrors = settings.getMirrors();
                        final ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();
                        for ( final Repository repo : repositories )
                        {
                            String id = repo.getId();
                            String url = repo.getUrl();

                            if ( mirrors != null )
                            {
                                final ArtifactRepositoryPolicy snapshots = convertPolicy( repo.getSnapshots() );
                                final ArtifactRepositoryPolicy releases = convertPolicy( repo.getReleases() );

                                final MavenArtifactRepository arepo =
                                    new MavenArtifactRepository( id, url, layout, snapshots, releases );

                                final Mirror mirror =
                                    mirrorSelector == null ? null : mirrorSelector.getMirror( arepo, mirrors );

                                if ( mirror != null )
                                {
                                    id = mirror.getId();
                                    url = mirror.getUrl();
                                }

                                SimpleHttpLocation addition = new SimpleHttpLocation( id, url, snapshots.isEnabled(), releases.isEnabled(), true, false, null );

                                addition.setAttribute(Location.CONNECTION_TIMEOUT_SECONDS, 60);

                                locs.add (addition);
                            }
                        }
                    }

                }
            }
        }
    }
}
 
开发者ID:release-engineering,项目名称:pom-manipulation-ext,代码行数:65,代码来源:MavenLocationExpander.java

示例14: mirrorAdjustsLocationURLs

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
@Test
public void mirrorAdjustsLocationURLs()
    throws Exception
{
    final Mirror mirror = new Mirror();
    mirror.setId( "test-mirror" );
    mirror.setMirrorOf( "*" );
    mirror.setUrl( "http://nowhere.com" );

    final ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();

    final ArtifactRepositoryPolicy snapshots =
        new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY,
                                      ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );

    final ArtifactRepositoryPolicy releases =
        new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER,
                                      ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );

    final File localRepo = File.createTempFile( "local.repo.", ".dir" );
    localRepo.deleteOnExit();

    final ArtifactRepository local =
        new MavenArtifactRepository( "local", localRepo.toURI()
                                                       .toString(), layout, snapshots, releases );

    final ArtifactRepository remote =
        new MavenArtifactRepository( "remote", "http:///repo.maven.apache.org/maven2", layout, snapshots, releases );

    final Settings settings = new Settings();
    settings.addMirror( mirror );

    final MavenLocationExpander ex =
        new MavenLocationExpander( Collections.<Location> emptyList(),
                                   Collections.<ArtifactRepository> singletonList( remote ), local,
                                   new DefaultMirrorSelector(), settings, Collections.<String> emptyList() );

    final List<Location> result = ex.expand( MavenLocationExpander.EXPANSION_TARGET );

    assertThat( result.size(), equalTo( 2 ) );

    final Iterator<Location> iterator = result.iterator();
    Location loc = iterator.next();

    assertThat( loc.getName(), equalTo( local.getId() ) );
    assertThat( loc.getUri(), equalTo( local.getUrl() ) );

    loc = iterator.next();

    assertThat( loc.getName(), equalTo( mirror.getId() ) );
    assertThat( loc.getUri(), equalTo( mirror.getUrl() ) );
}
 
开发者ID:release-engineering,项目名称:pom-manipulation-ext,代码行数:53,代码来源:MavenLocationExpanderTest.java

示例15: useActiveSettingsProfileRepos

import org.apache.maven.artifact.repository.MavenArtifactRepository; //导入依赖的package包/类
@Test
public void useActiveSettingsProfileRepos()
    throws Exception
{
    final ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();

    final ArtifactRepositoryPolicy snapshots =
        new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY,
                                      ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );

    final ArtifactRepositoryPolicy releases =
        new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER,
                                      ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );

    final File localRepo = File.createTempFile( "local.repo.", ".dir" );
    localRepo.deleteOnExit();

    final ArtifactRepository local =
        new MavenArtifactRepository( "local", localRepo.toURI()
                                                       .toString(), layout, snapshots, releases );

    final Repository remote = new Repository();
    remote.setId( "remote" );
    remote.setUrl( "http:///repo.maven.apache.org/maven2" );

    final Profile profile = new Profile();
    profile.setId( "test" );
    profile.addRepository( remote );

    final Settings settings = new Settings();
    settings.addProfile( profile );

    final MavenLocationExpander ex =
        new MavenLocationExpander( Collections.<Location> emptyList(),
                                   Collections.<ArtifactRepository> emptyList(), local,
                                   new DefaultMirrorSelector(), settings,
                                   Collections.<String> singletonList( profile.getId() ) );

    final List<Location> result = ex.expand( MavenLocationExpander.EXPANSION_TARGET );

    assertThat( result.size(), equalTo( 2 ) );

    final Iterator<Location> iterator = result.iterator();
    Location loc = iterator.next();

    assertThat( loc.getName(), equalTo( local.getId() ) );
    assertThat( loc.getUri(), equalTo( local.getUrl() ) );

    loc = iterator.next();

    assertThat( loc.getName(), equalTo( remote.getId() ) );
    assertThat( loc.getUri(), equalTo( remote.getUrl() ) );
}
 
开发者ID:release-engineering,项目名称:pom-manipulation-ext,代码行数:54,代码来源:MavenLocationExpanderTest.java


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