本文整理汇总了Java中org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout类的典型用法代码示例。如果您正苦于以下问题:Java DefaultRepositoryLayout类的具体用法?Java DefaultRepositoryLayout怎么用?Java DefaultRepositoryLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultRepositoryLayout类属于org.apache.maven.artifact.repository.layout包,在下文中一共展示了DefaultRepositoryLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provideLocalRepository
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的package包/类
/**
* maven-plugin-testing-harness can not inject local repositories (though the real runtime supports it).
* and the default stubs have no sufficient implementation of getPath():
* @see "http://maven.apache.org/plugin-testing/maven-plugin-testing-harness/examples/repositories.html"
*/
private ArtifactRepository provideLocalRepository() throws IllegalAccessException
{
DefaultArtifactRepositoryFactory factory = new DefaultArtifactRepositoryFactory();
setVariableValueToObject(factory, "factory", new org.apache.maven.repository.legacy.repository.DefaultArtifactRepositoryFactory());
LegacySupport legacySupport = new DefaultLegacySupport();
setVariableValueToObject(factory, "legacySupport", legacySupport);
ArtifactRepository localRepository = factory.createArtifactRepository("local", "http://localhost",
new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy());
setVariableValueToObject(localRepository, "basedir", LOCAL_REPOSITORY);
return localRepository;
}
示例2: createHelper
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的package包/类
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;
}
示例3: testFindArtifactInRepository
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的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);
}
示例4: setUpProject
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的package包/类
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 );
}
示例5: createHelper
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的package包/类
private VersionsHelper createHelper( String rulesUri, ArtifactMetadataSource metadataSource )
throws MojoExecutionException
{
final DefaultWagonManager wagonManager = new DefaultWagonManager()
{
public Wagon getWagon( Repository repository )
throws UnsupportedProtocolException, WagonConfigurationException
{
return new FileWagon();
}
};
VersionsHelper 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;
}
开发者ID:petr-ujezdsky,项目名称:versions-maven-plugin-svn-clone,代码行数:21,代码来源:DefaultVersionsHelperTest.java
示例6: convertFromMavenSettingsRepository
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的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;
}
示例7: toArtifactRepository
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的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;
}
示例8: resolve
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的package包/类
private Object resolve(String bundle) throws Exception, ArtifactNotFoundException {
if (!isMavenProtocol(bundle)) {
return bundle;
}
Artifact artifact = getArtifact(bundle);
if (bundle.indexOf(MVN_REPO_SEPARATOR) >= 0) {
if (bundle.startsWith(MVN_URI_PREFIX)) {
bundle = bundle.substring(MVN_URI_PREFIX.length());
}
String repo = bundle.substring(0, bundle.indexOf(MVN_REPO_SEPARATOR));
ArtifactRepository repository = new DefaultArtifactRepository(artifact.getArtifactId() + "-repo", repo,
new DefaultRepositoryLayout());
List<ArtifactRepository> repos = new LinkedList<ArtifactRepository>();
repos.add(repository);
resolver.resolve(artifact, repos, localRepo);
} else {
resolver.resolve(artifact, remoteRepos, localRepo);
}
if (artifact == null) {
throw new Exception("Unable to resolve artifact for uri " + bundle);
} else {
return artifact;
}
}
示例9: initialize
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的package包/类
protected void initialize() throws Exception {
basedir = getBasedir();
File settingsFile = new File(System.getProperty("user.home"), ".m2/settings.xml");
String localRepo = null;
if (settingsFile.exists()) {
Settings settings = new SettingsXpp3Reader().read(new FileReader(settingsFile));
localRepo = settings.getLocalRepository();
} else {
localRepo = System.getProperty("user.home") + "/.m2/repository";
}
if (localRepo == null) {
localRepo = System.getProperty("user.home") + "/.m2/repository";
}
localRepository = new DefaultArtifactRepository("local", "file://" + localRepo, new DefaultRepositoryLayout());
}
示例10: propagateRepositoryPolicies
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的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());
})
);
}
示例11: repo
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的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;
}
示例12: testCreateEffectivePom
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的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 );
}
示例13: testExecute
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的package包/类
/**
* 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();
}
示例14: setUp
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的package包/类
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());
}
示例15: testExecute
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; //导入依赖的package包/类
/**
* 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();
}