本文整理汇总了Java中org.apache.ivy.Ivy类的典型用法代码示例。如果您正苦于以下问题:Java Ivy类的具体用法?Java Ivy怎么用?Java Ivy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Ivy类属于org.apache.ivy包,在下文中一共展示了Ivy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIvy
import org.apache.ivy.Ivy; //导入依赖的package包/类
@Nullable
private Ivy getIvy( CommandInvocation invocation, boolean verbose, PrintStream err ) {
Set<URL> repositories = invocation.hasOption( REPOSITORIES_OPTION )
? invocation.getAllArgumentsFor( REPOSITORIES_OPTION )
.stream().map( ( it ) -> {
try {
return new URL( it );
} catch ( MalformedURLException e ) {
throw new RuntimeException( "Invalid URL: " + it );
}
} ).collect( Collectors.toSet() )
: null;
if ( verbose ) {
if ( repositories == null ) {
err.println( "No remote Ivy repositories are configured, using default: " + IvyFactory.JCENTER );
} else {
err.println( "Current Ivy repositories: " + String.join( ", ",
repositories.stream().map( Object::toString ).toArray( String[]::new ) ) );
}
}
return ivyFactory.getIvy( repositories, !invocation.hasOption( NO_MAVEN_LOCAL_OPTION ), err );
}
示例2: getIvy
import org.apache.ivy.Ivy; //导入依赖的package包/类
/**
* Create or re-use an Ivy instance using the provided repositories.
*
* @param repositories URL to Maven repositories or null to use the default repositories (JCenter).
* @param includeMavenLocal include the Maven local repository
* @param out stream to be used to log information
* @return Ivy instance (may be re-used) or null if this factory is not ready yet.
*/
@Nullable
Ivy getIvy( @Nullable Set<URL> repositories, boolean includeMavenLocal, PrintStream out ) {
if ( !ready.get() ) {
return null;
}
if ( repositories == null ) {
repositories = defaultRepositories;
}
RepositoryConfig config = new RepositoryConfig( repositories, includeMavenLocal );
if ( !ivyByConfig.containsKey( config ) ) {
ivyByConfig.put( config, createIvyWith( config, out ) );
}
return ivyByConfig.get( config );
}
示例3: setUp
import org.apache.ivy.Ivy; //导入依赖的package包/类
@Before
public void setUp()
throws Exception
{
resolver = createMock( Resolver.class );
deployer = createStrictMock( Deployer.class );
visitor = createMock( ReportVisitor.class );
IvyResolver ivyResolver = new IvyResolver();
ivyResolver.setResolver( resolver );
ivyResolver.setDeployer( deployer );
IvySettings settings = new IvySettings();
settings.addResolver( ivyResolver );
settings.setDefaultResolver( "XMvn" );
ivy = Ivy.newInstance( settings );
}
示例4: prettyPrint
import org.apache.ivy.Ivy; //导入依赖的package包/类
public String prettyPrint() {
final StringBuilder sb = new StringBuilder();
sb.append("\n------------------------------------------------------------\nGradle ");
sb.append(getVersion());
sb.append("\n------------------------------------------------------------\n\nBuild time: ");
sb.append(getBuildTime());
sb.append("\nBuild number: ");
sb.append(buildNumber);
sb.append("\nRevision: ");
sb.append(commitId);
sb.append("\n\nGroovy: ");
sb.append(GroovySystem.getVersion());
sb.append("\nAnt: ");
sb.append(Main.getAntVersion());
sb.append("\nIvy: ");
sb.append(Ivy.getIvyVersion());
sb.append("\nJVM: ");
sb.append(Jvm.current());
sb.append("\nOS: ");
sb.append(OperatingSystem.current());
sb.append("\n");
return sb.toString();
}
示例5: testNoArtifact
import org.apache.ivy.Ivy; //导入依赖的package包/类
@Test
public void testNoArtifact() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-noartifact.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
assertNotNull(md.getConfigurations());
assertEquals(Collections.singletonList(new Configuration("default")),
Arrays.asList(md.getConfigurations()));
assertNotNull(md.getArtifacts("default"));
assertEquals(0, md.getArtifacts("default").length);
assertNotNull(md.getDependencies());
assertEquals(0, md.getDependencies().length);
}
示例6: testMaven
import org.apache.ivy.Ivy; //导入依赖的package包/类
@Test
public void testMaven() throws Exception {
Ivy ivy = Ivy.newInstance();
ivy.configure(new File("test/repositories/ivysettings.xml"));
@SuppressWarnings("unused")
ResolveReport rr = ivy.install(ModuleRevisionId.newInstance("org.apache", "test", "1.0"),
ivy.getSettings().getDefaultResolver().getName(), "install", new InstallOptions());
assertTrue(new File("build/test/install/org.apache/test/ivy-1.0.xml").exists());
assertTrue(new File("build/test/install/org.apache/test/test-1.0.jar").exists());
// the original descriptor is not installed
assertFalse(new File("build/test/install/org.apache/test/test-1.0.pom").exists());
ivy.install(ModuleRevisionId.newInstance("org.apache", "test", "1.0"), ivy.getSettings()
.getDefaultResolver().getName(), "install", new InstallOptions()
.setInstallOriginalMetadata(true).setOverwrite(true));
// the original descriptor is installed now, too
assertTrue(new File("build/test/install/org.apache/test/test-1.0.pom").exists());
}
示例7: testSimple
import org.apache.ivy.Ivy; //导入依赖的package包/类
@Test
public void testSimple() throws Exception {
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-simple.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
assertNotNull(md.getConfigurations());
assertEquals(Collections.singletonList(new Configuration("default")),
Arrays.asList(md.getConfigurations()));
assertNotNull(md.getArtifacts("default"));
assertEquals(1, md.getArtifacts("default").length);
assertEquals("mymodule", md.getArtifacts("default")[0].getName());
assertEquals("jar", md.getArtifacts("default")[0].getType());
assertNotNull(md.getDependencies());
assertEquals(0, md.getDependencies().length);
}
示例8: testLatestTime2
import org.apache.ivy.Ivy; //导入依赖的package包/类
@Test
public void testLatestTime2() throws Exception {
ivy = new Ivy();
ivy.configure(LatestConflictManagerTest.class.getResource("ivysettings-latest-time.xml"));
ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);
// set timestamps, because svn is not preserving this information,
// and the latest time strategy is relying on it
long time = System.currentTimeMillis() - 10000;
new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").setLastModified(time);
new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.2.jar")
.setLastModified(time + 2000);
ResolveReport report = ivy.resolve(
LatestConflictManagerTest.class.getResource("ivy-latest-time-2.xml"),
getResolveOptions());
ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
for (ModuleRevisionId mrid : defaultReport.getModuleRevisionIds()) {
if (mrid.getName().equals("mod1.1")) {
assertEquals("1.0", mrid.getRevision());
} else if (mrid.getName().equals("mod1.2")) {
assertEquals("2.2", mrid.getRevision());
}
}
}
示例9: testResolveMaven2Snapshot1
import org.apache.ivy.Ivy; //导入依赖的package包/类
/**
* Test case for IVY-501.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-501">IVY-501</a>
*/
@Test
public void testResolveMaven2Snapshot1() throws Exception {
// here we test maven SNAPSHOT versions handling,
// with m2 snapshotRepository/uniqueVersion set to true
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
ResolveReport report = ivy.resolve(new File(
"test/repositories/m2/org/apache/test4/1.0/test4-1.0.pom"),
getResolveOptions(new String[] {"*"}));
assertNotNull(report);
assertFalse(report.hasError());
// dependencies
assertTrue(getIvyFileInCache(
ModuleRevisionId.newInstance("org.apache", "test-SNAPSHOT1", "2.0.2-SNAPSHOT"))
.exists());
assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-SNAPSHOT1", "2.0.2-SNAPSHOT",
"test-SNAPSHOT1", "jar", "jar").exists());
}
示例10: addCleanableForSingleContainer
import org.apache.ivy.Ivy; //导入依赖的package包/类
private void addCleanableForSingleContainer(MenuManager menuManager,
List<MenuManager> items, Ivy ivy) {
List<Cleanable> allCleanables = new ArrayList<>();
List<Cleanable> repositoryCleanables = new ArrayList<>();
List<Cleanable> resolutionCleanables = new ArrayList<>();
addResolutionCleanable(allCleanables, ivy);
addResolutionCleanable(resolutionCleanables, ivy);
addRepositoryCleanable(allCleanables, ivy);
addRepositoryCleanable(repositoryCleanables, ivy);
addCleanable(menuManager, items, "Clean all caches", allCleanables);
addCleanable(menuManager, items, "Clean the resolution cache", resolutionCleanables);
addCleanable(menuManager, items, "Clean every repository cache", repositoryCleanables);
for (Cleanable cleanable : resolutionCleanables) {
addCleanable(menuManager, items, "Clean the cache '" + cleanable.getName() + "'",
Collections.singletonList(cleanable));
}
}
示例11: testResolveWithConflictManagerPerModule
import org.apache.ivy.Ivy; //导入依赖的package包/类
/**
* Test case for IVY-448.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-448">IVY-448</a>
*/
@Test
public void testResolveWithConflictManagerPerModule() throws Exception {
// all modules from myorg
// module1
// -> module2-1.0
// -> module3-2.0
// module2
// -> module3-1.0
// settings use 'all' as default conflict manager, and latest-revision for modules from
// myorg
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/IVY-448/ivysettings.xml"));
ResolveReport report = ivy.resolve(new File("test/repositories/IVY-448/ivy.xml"),
getResolveOptions(new String[] {"*"}));
assertFalse(report.hasError());
// rev 1.0 should have been evicted by latest-revision conflict manager
assertTrue(getArchiveFileInCache(ivy, "myorg", "module3", "2.0", "module3", "jar", "jar")
.exists());
assertFalse(getArchiveFileInCache(ivy, "myorg", "module3", "1.0", "module3", "jar", "jar")
.exists());
}
示例12: testResolveMaven2GetSourcesWithSrcClassifier
import org.apache.ivy.Ivy; //导入依赖的package包/类
/**
* Test case for IVY-1138.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1138">IVY-1138</a>
*/
@Test
public void testResolveMaven2GetSourcesWithSrcClassifier() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-m2-with-src.xml"),
getResolveOptions(new String[] {"*"}));
assertNotNull(report);
assertFalse(report.hasError());
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test-src", "1.0"))
.exists());
File jarFileInCache = getArchiveFileInCache(ivy, "org.apache", "test-src", "1.0",
"test-src", "jar", "jar");
assertTrue(jarFileInCache.exists());
File sourceFileInCache = getArchiveFileInCache(ivy, "org.apache", "test-src", null, "1.0",
"test-src", "source", "jar", Collections.singletonMap("classifier", "src"));
assertTrue(sourceFileInCache.exists());
assertTrue(jarFileInCache.length() != sourceFileInCache.length());
}
示例13: shouldConfigureEasyAntIvyInstanceWithSettingsFileFromConfiguration
import org.apache.ivy.Ivy; //导入依赖的package包/类
@Test
public void shouldConfigureEasyAntIvyInstanceWithSettingsFileFromConfiguration() throws URISyntaxException {
File f = new File(this.getClass().getResource("/repositories/easyant-ivysettings-test.xml").toURI());
easyAntConfiguration.setEasyantIvySettingsFile(f.getAbsolutePath());
IvyAntSettings configuredEasyAntIvyInstance = easyantEngine.configureEasyAntIvyInstance(project);
assertThat(project.getReference(EasyAntMagicNames.EASYANT_IVY_INSTANCE), instanceOf(IvyAntSettings.class));
assertThat(project.getProperty(EasyAntMagicNames.EASYANT_DEFAULT_IVYSETTINGS),
is(this.getClass().getResource("/org/apache/easyant/core/default-easyant-ivysettings.xml")
.toExternalForm()));
assertThat(Boolean.valueOf(project.getProperty(EasyAntMagicNames.IGNORE_USER_IVYSETTINGS)), is(false));
assertThat(project.getProperty(EasyAntMagicNames.OFFLINE_EASYANT_RESOLVER),
is(EasyAntConstants.DEFAULT_OFFLINE_EASYANT_RESOLVER));
assertThat(project.getProperty(EasyAntMagicNames.OFFLINE_BASE_DIRECTORY), is(project.getBaseDir()
.getAbsolutePath() + "/offline/"));
IvyAntSettings easyantIvySettings = IvyInstanceHelper.getEasyAntIvyAntSettings(project);
Ivy ivyInstance = easyantIvySettings.getConfiguredIvyInstance(null);
assertThat(ivyInstance.getResolutionCacheManager(), instanceOf(EasyantResolutionCacheManager.class));
assertTrue(containsClass(Arrays.asList(ivyInstance.getSettings().getRepositoryCacheManagers()), EasyAntRepositoryCacheManager.class));
assertThat(configuredEasyAntIvyInstance, sameInstance(easyantIvySettings));
}
示例14: testResolveSeveralDefaultWithArtifactsAndConfs
import org.apache.ivy.Ivy; //导入依赖的package包/类
/**
* Test case for IVY-283.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-283">IVY-283</a>
*/
@Test
public void testResolveSeveralDefaultWithArtifactsAndConfs() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/IVY-283/ivysettings.xml"));
ResolveReport report = ivy.resolve(new File("test/repositories/IVY-283/ivy.xml"),
getResolveOptions(new String[] {"*"}));
assertFalse(report.hasError());
// dependencies
ConfigurationResolveReport crr = report.getConfigurationReport("build");
assertNotNull(crr);
assertEquals(3,
crr.getDownloadReports(ModuleRevisionId.newInstance("medicel", "C", "1.0")).length);
assertTrue(getArchiveFileInCache(ivy, "medicel", "C", "1.0", "lib_c_a", "jar", "jar")
.exists());
assertTrue(getArchiveFileInCache(ivy, "medicel", "C", "1.0", "lib_c_b", "jar", "jar")
.exists());
assertTrue(getArchiveFileInCache(ivy, "medicel", "C", "1.0", "lib_c_d", "jar", "jar")
.exists());
}
示例15: getReportUrl
import org.apache.ivy.Ivy; //导入依赖的package包/类
public URL getReportUrl() {
Ivy ivy = state.getCachedIvy();
if (ivy == null) {
return null;
}
ModuleDescriptor md = state.getCachedModuleDescriptor(ivy);
if (md == null) {
return null;
}
String resolveId = IvyClasspathUtil.buildResolveId(conf.getInheritedAdvancedSetup()
.isUseExtendedResolveId(), md);
try {
return ivy
.getResolutionCacheManager()
.getConfigurationResolveReportInCache(resolveId, md.getConfigurationsNames()[0])
.toURI().toURL();
} catch (MalformedURLException e) {
// should never happen
throw new RuntimeException(e);
}
}