org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout Java Examples
The following examples show how to use
org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RepositoryUtils.java From furnace with Eclipse Public License 1.0 | 6 votes |
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; }
Example #2
Source File: AbstractUnleashMojo.java From unleash-maven-plugin with Eclipse Public License 1.0 | 6 votes |
@MojoProduces @Named("additionalDeployemntRepositories") private Set<RemoteRepository> getAdditionalDeploymentRepositories() { Set<Repository> repos = new HashSet<>(); if (this.additionalDeploymentRepositories != null) { repos.addAll(this.additionalDeploymentRepositories); } System.getProperties().forEach((key, value) -> { if (key.toString().startsWith(PROPERTY_REPO_BASE)) { Repository.parseFromProperty(value.toString()).ifPresent(repo -> repos.add(repo)); } }); return repos.stream().map(repo -> { DefaultRepositoryLayout layout = new DefaultRepositoryLayout(); ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy(); ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy(); ArtifactRepository artifactRepository = new MavenArtifactRepository(repo.getId(), repo.getUrl(), layout, snapshotsPolicy, releasesPolicy); this.settings.getServers().stream().filter(server -> Objects.equals(server.getId(), repo.getId())).findFirst() .ifPresent(server -> artifactRepository.setAuthentication(createServerAuthentication(server))); return RepositoryUtils.toRepo(artifactRepository); }).collect(Collectors.toSet()); }
Example #3
Source File: MavenArtifactResolvingHelperTest.java From thorntail with Apache License 2.0 | 6 votes |
@Test // SWARM-1173: swarm-plugin trying to download SNAPSHOTs from Maven Central public void propagateRepositoryPolicies() { 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()); }) ); }
Example #4
Source File: RepositoryUtils.java From furnace with Eclipse Public License 1.0 | 6 votes |
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; }
Example #5
Source File: DefaultVersionsHelperTest.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
private DefaultVersionsHelper createHelper( String rulesUri, ArtifactMetadataSource metadataSource ) throws MojoExecutionException { final DefaultWagonManager wagonManager = new DefaultWagonManager() { public Wagon getWagon( Repository repository ) throws UnsupportedProtocolException, WagonConfigurationException { return new FileWagon(); } }; DefaultVersionsHelper helper = new DefaultVersionsHelper( new DefaultArtifactFactory(), new DefaultArtifactResolver(), metadataSource, new ArrayList(), new ArrayList(), new DefaultArtifactRepository( "", "", new DefaultRepositoryLayout() ), wagonManager, new Settings(), "", rulesUri, mock( Log.class ), mock( MavenSession.class ), new DefaultPathTranslator()); return helper; }
Example #6
Source File: AbstractJnlpMojoTest.java From webstart with MIT License | 6 votes |
private void setUpProject( File pomFile, AbstractMojo mojo ) throws Exception { MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, "never", "never" ); String localRepoUrl = "file://" + System.getProperty( "user.home" ) + "/.m2/repository"; ArtifactRepository localRepository = artifactRepositoryFactory.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), policy, policy ); ProfileManager profileManager = new DefaultProfileManager( getContainer() ); MavenProject project = projectBuilder.buildWithDependencies( pomFile, localRepository, profileManager ); //this gets the classes for these tests of this mojo (exec plugin) onto the project classpath for the test project.getBuild().setOutputDirectory( new File( "target/test-classes" ).getAbsolutePath() ); setVariableValueToObject( mojo, "project", project ); }
Example #7
Source File: RunEpisodesBPlugin.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
protected void setUp() throws Exception { super.setUp(); mavenProjectBuilder = (MavenProjectBuilder) getContainer().lookup( MavenProjectBuilder.ROLE); ArtifactFactory artifactFactory = (ArtifactFactory) getContainer() .lookup(ArtifactFactory.ROLE); final Map<String, Mojo> mojos = (Map<String, Mojo>) getContainer() .lookupMap(Mojo.ROLE); for (Mojo mojo : mojos.values()) { if (mojo instanceof Hyperjaxb3Mojo) { this.mojo = (Hyperjaxb3Mojo) mojo; } } MavenSettingsBuilder settingsBuilder = (MavenSettingsBuilder) getContainer() .lookup(MavenSettingsBuilder.ROLE); ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) getContainer() .lookup(ArtifactRepositoryLayout.ROLE, "default"); Settings settings = settingsBuilder.buildSettings(); String url = settings.getLocalRepository(); if (!url.startsWith("file:")) { url = "file://" + url; } localRepository = new DefaultArtifactRepository("local", url, new DefaultRepositoryLayout()); }
Example #8
Source File: Maven3DependencyTreeBuilder.java From archiva with Apache License 2.0 | 5 votes |
MavenRepositorySystem initMaven() throws IllegalAccessException { MavenRepositorySystem system = new MavenRepositorySystem( ); DefaultArtifactHandlerManager afm = new DefaultArtifactHandlerManager( ); DefaultRepositoryLayout layout = new DefaultRepositoryLayout( ); FieldUtils.writeField( system, "artifactHandlerManager", afm, true); Map<String, ArtifactRepositoryLayout> map = new HashMap<>( ); map.put( "defaultRepositoryLayout", layout ); FieldUtils.writeField( system, "layouts", map, true); return system; }
Example #9
Source File: JAXBGenerateTest.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 5 votes |
/** * Validate the generation of a java files from purchaseorder.xsd. * * @throws MojoExecutionException */ public void testExecute() throws Exception { final File pom = new File(getBaseDir(), "src/test/resources/test-pom.xml"); final ArtifactRepository localRepository = new DefaultArtifactRepository( "local", new File(getBaseDir(), "target/test-repository").toURI().toURL().toString() , new DefaultRepositoryLayout()); final MavenProject mavenProject = mavenProjectBuilder.build(pom, localRepository, null); final XJC2Mojo generator = (XJC2Mojo) lookupMojo("generate", pom); generator.setProject(mavenProject); generator.setLocalRepository(localRepository); generator.setSchemaDirectory(new File(getBaseDir(),"src/test/resources/")); generator.setSchemaIncludes(new String[] { "*.xsd" }); generator.setBindingIncludes(new String[] { "*.xjb" }); generator.setGenerateDirectory(new File(getBaseDir(), "target/test/generated-sources")); generator.setVerbose(true); generator.setGeneratePackage("unittest"); generator.setRemoveOldOutput(false); generator.execute(); }
Example #10
Source File: JAXBGenerateTest.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 5 votes |
/** * Validate the generation of a java files from purchaseorder.xsd. * * @throws MojoExecutionException */ public void testExecute() throws Exception { final File pom = new File(getBaseDir(), "src/test/resources/test-pom.xml"); final ArtifactRepository localRepository = new DefaultArtifactRepository( "local", new File(getBaseDir(), "target/test-repository").toURI().toURL().toString() , new DefaultRepositoryLayout()); final MavenProject mavenProject = mavenProjectBuilder.build(pom, localRepository, null); final XJC21Mojo generator = (XJC21Mojo) lookupMojo("generate", pom); generator.setProject(mavenProject); generator.setLocalRepository(localRepository); generator.setSchemaDirectory(new File(getBaseDir(),"src/test/resources/")); generator.setSchemaIncludes(new String[] { "*.xsd" }); generator.setBindingIncludes(new String[] { "*.xjb" }); generator.setGenerateDirectory(new File(getBaseDir(), "target/test/generated-sources")); generator.setVerbose(true); generator.setGeneratePackage("unittest"); generator.setRemoveOldOutput(false); generator.execute(); }
Example #11
Source File: MavenDependencyUtil.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
/** * maven仓库处理 * * @return * @throws Exception */ private static ArtifactRepository localRepository() throws Exception { if (mavenHome == null) { getMavenHome(); } SettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); request.setGlobalSettingsFile(new File(mavenHome, "/conf/settings.xml")); DefaultSettingsBuilder builder = new DefaultSettingsBuilderFactory().newInstance(); SettingsBuildingResult ret = builder.build(request); String path = ret.getEffectiveSettings().getLocalRepository(); path = path == null ? String.format("%s%s", System.getProperty("user.home"), "\\.m2\\repository") : path; return FACTORY.createArtifactRepository("local", "file://" + path, (ArtifactRepositoryLayout) new DefaultRepositoryLayout(), null, null); }
Example #12
Source File: RunPoPlugin.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
/** * Validate the generation of a java files from purchaseorder.xsd. * * @throws MojoExecutionException */ public void testExecute() throws Exception { final File pom = new File(getBaseDir(), "pom.xml"); final ArtifactRepository localRepository = new DefaultArtifactRepository( "local", new File(getBaseDir(), "target/test-repository").toURI() .toURL().toString(), new DefaultRepositoryLayout()); final MavenProject mavenProject = mavenProjectBuilder.build(pom, localRepository, null); final Hyperjaxb3Mojo generator = (Hyperjaxb3Mojo) lookupMojo( "org.jvnet.hyperjaxb3", "hyperjaxb3-maven-plugin", "0.5.4-SNAPSHOT", "generate", null); generator.setProject(mavenProject); generator.setLocalRepository(localRepository); generator.setSchemaDirectory(new File(getBaseDir(), "src/main/resources")); generator.setSchemaIncludes(new String[] { "*.xsd" }); generator.setBindingIncludes(new String[] { "*.xjb" }); generator.setGenerateDirectory(new File(getBaseDir(), "target/test/generated-sources")); generator.setVerbose(true); generator.setRemoveOldOutput(true); generator.execute(); }
Example #13
Source File: CreateEffectivePomTest.java From flatten-maven-plugin with Apache License 2.0 | 5 votes |
/** * 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 ); setDeclaredField( tested, "modelBuilderThreadSafetyWorkaround", buildModelBuilderThreadSafetyWorkaroundForTest() ); Model effectivePom = tested.createEffectivePom( buildingRequest, false, FlattenMode.defaults ); assertThat( effectivePom.getName() ).isEqualTo( magicValue ); }
Example #14
Source File: DependencyResolver.java From spring-cloud-function with Apache License 2.0 | 5 votes |
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; }
Example #15
Source File: DependencyResolver.java From spring-init with Apache License 2.0 | 5 votes |
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; }
Example #16
Source File: VersioningCalculatorTest.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
@SuppressWarnings( "deprecation" ) private VersioningState setupSession( final Properties properties, final Map<ProjectRef, String[]> versionMap ) throws Exception { // Originally the default used to be 0, this was changed to be 5 but this affects this test suite so revert // just for these tests. if ( ! properties.containsKey( VersioningState.INCREMENT_SERIAL_SUFFIX_PADDING_SYSPROP ) ) { properties.setProperty( VersioningState.INCREMENT_SERIAL_SUFFIX_PADDING_SYSPROP, "0" ); } final ArtifactRepository ar = new MavenArtifactRepository( "test", TestUtils.MVN_CENTRAL, new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties( properties ) .setRemoteRepositories( Collections.singletonList( 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; }
Example #17
Source File: MavenLocationExpander.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
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); } } } } } } } }
Example #18
Source File: MavenLocationExpanderTest.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
@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() ) ); }
Example #19
Source File: MavenLocationExpanderTest.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
@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() ) ); }
Example #20
Source File: MavenLocationExpanderTest.java From pom-manipulation-ext with Apache License 2.0 | 4 votes |
@Test public void locationURLs() 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 ArtifactRepository remote = new MavenArtifactRepository( "remote", "http:///repo.maven.apache.org/maven2", layout, snapshots, releases ); final Settings settings = new Settings(); 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( remote.getId() ) ); assertThat( loc.getUri(), equalTo( remote.getUrl() ) ); }
Example #21
Source File: AbstractDaemonGeneratorTest.java From appassembler with MIT License | 2 votes |
public void runTest( String generatorId, String pom, String descriptor, String outputPath ) throws Exception { File outputDir = getTestFile( outputPath ); DaemonGenerator generator = (DaemonGenerator) lookup( DaemonGenerator.ROLE, generatorId ); // ----------------------------------------------------------------------- // Build the MavenProject instance // ----------------------------------------------------------------------- MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); MavenSettingsBuilder settingsBuilder = (MavenSettingsBuilder) lookup( MavenSettingsBuilder.ROLE ); Settings settings = settingsBuilder.buildSettings(); ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); String localRepoUrl = new File( settings.getLocalRepository() ).toURL().toExternalForm(); ArtifactRepository localRepository = artifactRepositoryFactory.createDeploymentArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), false ); ProfileManager profileManager = new DefaultProfileManager( getContainer() ); File tempPom = createFilteredFile( pom ); MavenProject project = projectBuilder.buildWithDependencies( tempPom, localRepository, profileManager ); // ----------------------------------------------------------------------- // Clean the output directory // ----------------------------------------------------------------------- FileUtils.deleteDirectory( outputDir ); FileUtils.forceMkdir( outputDir ); // ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- DaemonGeneratorService daemonGeneratorService = (DaemonGeneratorService) lookup( DaemonGeneratorService.ROLE ); Daemon model = daemonGeneratorService.loadModel( getTestFile( descriptor ) ); generator.generate( new DaemonGenerationRequest( model, project, localRepository, outputDir, "bin" ) ); }