You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jl...@apache.org on 2014/11/24 20:03:56 UTC
[3/3] ant-easyant-core git commit: Fix EASYANT-71 Offline mode does not retrieve transitive dependencies of the project (thanks to Jérôme Leroux)
Fix EASYANT-71 Offline mode does not retrieve transitive dependencies of the project (thanks to Jérôme Leroux)
Project: http://git-wip-us.apache.org/repos/asf/ant-easyant-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-easyant-core/commit/c61c43ee
Tree: http://git-wip-us.apache.org/repos/asf/ant-easyant-core/tree/c61c43ee
Diff: http://git-wip-us.apache.org/repos/asf/ant-easyant-core/diff/c61c43ee
Branch: refs/heads/master
Commit: c61c43ee3c56ba6d3fe0c0ad91d366a486ee8f5c
Parents: ab296d6
Author: Jean-Louis Boudart <je...@gmail.com>
Authored: Mon Nov 24 20:02:48 2014 +0100
Committer: Jean-Louis Boudart <je...@gmail.com>
Committed: Mon Nov 24 20:02:48 2014 +0100
----------------------------------------------------------------------
src/documentation/ref/OfflineMode.html | 2 +-
.../org/apache/easyant/tasks/GoOffline.java | 1 +
.../apache/easyant/tasks/AntTaskBaseTest.java | 8 ++
.../org/apache/easyant/tasks/GoOfflineTest.java | 82 ++++++++++++++++----
src/test/resources/ivysettings-test.xml | 2 +-
.../easyant/tasks/dependencies/module.ivy | 33 ++++++++
6 files changed, 112 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant-easyant-core/blob/c61c43ee/src/documentation/ref/OfflineMode.html
----------------------------------------------------------------------
diff --git a/src/documentation/ref/OfflineMode.html b/src/documentation/ref/OfflineMode.html
index c5480d0..268b987 100644
--- a/src/documentation/ref/OfflineMode.html
+++ b/src/documentation/ref/OfflineMode.html
@@ -34,7 +34,7 @@ EasyAnt cames with offline mode support. This feature is designed to bring all r
<li>plugins used by the project</li>
</ul>
-Before going offline you'll need to tell easyant to fetch everything by invoking "offline:go-offline" target. All your resources will be fetched in ".offline" directory. You'll need to invoke it again if you add new plugins / dependencies.
+Before going offline you'll need to tell easyant to fetch everything by invoking "offline:go-offline" target. All your resources will be fetched in "offline" directory. You'll need to invoke it again if you add new plugins / dependencies.
Once your resources are ready to be used offline you can tell easyant you're offline by using --offline switch (or -o in shorter form).
http://git-wip-us.apache.org/repos/asf/ant-easyant-core/blob/c61c43ee/src/main/java/org/apache/easyant/tasks/GoOffline.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/easyant/tasks/GoOffline.java b/src/main/java/org/apache/easyant/tasks/GoOffline.java
index cbe183b..d67041e 100644
--- a/src/main/java/org/apache/easyant/tasks/GoOffline.java
+++ b/src/main/java/org/apache/easyant/tasks/GoOffline.java
@@ -129,6 +129,7 @@ public class GoOffline extends AbstractEasyAntTask {
install.setRevision(moduleRevisionId.getRevision());
install.setOverwrite(true);
install.setHaltonfailure(false);
+ install.setTransitive(true);
initTask(install).execute();
}
http://git-wip-us.apache.org/repos/asf/ant-easyant-core/blob/c61c43ee/src/test/java/org/apache/easyant/tasks/AntTaskBaseTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/easyant/tasks/AntTaskBaseTest.java b/src/test/java/org/apache/easyant/tasks/AntTaskBaseTest.java
index 9f8d92a..c4a7998 100644
--- a/src/test/java/org/apache/easyant/tasks/AntTaskBaseTest.java
+++ b/src/test/java/org/apache/easyant/tasks/AntTaskBaseTest.java
@@ -18,9 +18,12 @@
package org.apache.easyant.tasks;
import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
+import java.io.File;
+
import org.apache.tools.ant.Project;
public class AntTaskBaseTest {
@@ -48,6 +51,11 @@ public class AntTaskBaseTest {
String realLog = antTestListener.getLog();
assertThat(realLog, not(containsString(substring)));
}
+
+ public void assertFileExists(File root, String relativeFilename){
+ File file = new File(root.getAbsolutePath() + relativeFilename);
+ assertThat(file.exists(), is(true));
+ }
private void checkAntListener() {
if (antTestListener == null) {
http://git-wip-us.apache.org/repos/asf/ant-easyant-core/blob/c61c43ee/src/test/java/org/apache/easyant/tasks/GoOfflineTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/easyant/tasks/GoOfflineTest.java b/src/test/java/org/apache/easyant/tasks/GoOfflineTest.java
index 6403615..c9b8c45 100644
--- a/src/test/java/org/apache/easyant/tasks/GoOfflineTest.java
+++ b/src/test/java/org/apache/easyant/tasks/GoOfflineTest.java
@@ -44,10 +44,12 @@ import org.junit.rules.TemporaryFolder;
public class GoOfflineTest extends AntTaskBaseTest {
private static final String EASYANT_BUILDSCOPE_REP = "easyant-buildscope-rep";
+ private static final String PROJECT_BUILDSCOPE_REP = "project-buildscope-rep";
private GoOffline goOffline;
private File easyantBuildScopeRepoFolder;
+ private File projectBuildScopeRepoFolder;
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -63,17 +65,17 @@ public class GoOfflineTest extends AntTaskBaseTest {
File cache = folder.newFolder("build-cache");
project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
+ File projectCache = folder.newFolder("easyant-cache-test");
+ project.setProperty("easyant.default.cache.dir", projectCache.getAbsolutePath());
- IvyConfigure configure = new IvyConfigure();
- configure.setSettingsId(EasyAntMagicNames.EASYANT_IVY_INSTANCE);
- configure.setProject(project);
- configure.setFile(new File(this.getClass().getResource("/repositories/easyant-ivysettings-test.xml").toURI()));
- configure.execute();
+ configureEasyantSettings(project);
+ configureProjectSettings(project);
project.setBaseDir(new File(this.getClass().getResource("simple").toURI()));
configurePluginService(project);
configureEasyantBuildScopeRepository(project);
+ configureProjectBuildScopeRepository(project);
goOffline = new GoOffline();
goOffline.setProject(project);
@@ -82,19 +84,50 @@ public class GoOfflineTest extends AntTaskBaseTest {
}
+ private void configureEasyantSettings(Project project) throws URISyntaxException{
+ configureSettings(project, EasyAntMagicNames.EASYANT_IVY_INSTANCE, "/repositories/easyant-ivysettings-test.xml");
+ }
+
+ private void configureProjectSettings(Project project) throws URISyntaxException{
+ configureSettings(project, IvyInstanceHelper.getProjectIvyInstanceName(project), "/ivysettings-test.xml");
+ }
+
+ private void configureSettings(Project project, String settingsId, String settingsFile) throws URISyntaxException{
+ IvyConfigure configure = new IvyConfigure();
+ configure.setSettingsId(settingsId);
+ configure.setProject(project);
+ configure.setFile(new File(this.getClass().getResource(settingsFile).toURI()));
+ configure.execute();
+ }
+
private void configureEasyantBuildScopeRepository(Project project) throws IOException {
easyantBuildScopeRepoFolder = folder.newFolder("ea-build-repo");
-
- FileSystemResolver easyantBuildScopeRepo = new FileSystemResolver();
- easyantBuildScopeRepo.setName(EASYANT_BUILDSCOPE_REP);
- easyantBuildScopeRepo.addArtifactPattern(easyantBuildScopeRepoFolder.getAbsolutePath()
- + "/[organisation]/[module]/[revision]/[artifact](-[classifier]).[ext]");
- easyantBuildScopeRepo.addIvyPattern(easyantBuildScopeRepoFolder.getAbsolutePath()
- + "/[organisation]/[module]/[revision]/[artifact](-[classifier]).[ext]");
-
+ FileSystemResolver resolver = newResolver(project, easyantBuildScopeRepoFolder, EASYANT_BUILDSCOPE_REP);
+
Ivy easyantIvyInstance = IvyInstanceHelper.getEasyAntIvyAntSettings(project)
.getConfiguredIvyInstance(goOffline);
- easyantIvyInstance.getSettings().addResolver(easyantBuildScopeRepo);
+ easyantIvyInstance.getSettings().addResolver(resolver);
+ }
+
+ private void configureProjectBuildScopeRepository(Project project) throws IOException {
+ projectBuildScopeRepoFolder = folder.newFolder("project-build-repo");
+ FileSystemResolver resolver = newResolver(project, projectBuildScopeRepoFolder, PROJECT_BUILDSCOPE_REP);
+
+ Ivy projecttIvyInstance = IvyInstanceHelper.getProjectIvyAntSettings(project)
+ .getConfiguredIvyInstance(goOffline);
+ projecttIvyInstance.getSettings().addResolver(resolver);
+ }
+
+ private FileSystemResolver newResolver(Project project, File repoFolder, String resolverName ) throws IOException {
+
+ FileSystemResolver resolver = new FileSystemResolver();
+ resolver.setName(resolverName);
+ resolver.addArtifactPattern(repoFolder.getAbsolutePath()
+ + "/[organisation]/[module]/[revision]/[artifact](-[classifier]).[ext]");
+ resolver.addIvyPattern(repoFolder.getAbsolutePath()
+ + "/[organisation]/[module]/[revision]/[artifact](-[classifier]).[ext]");
+
+ return resolver;
}
private void configurePluginService(Project project) {
@@ -140,4 +173,25 @@ public class GoOfflineTest extends AntTaskBaseTest {
+ "/mycompany/simpleplugin/0.1/simpleplugin.ant");
assertThat(antFile.exists(), is(true));
}
+
+ @Test
+ public void shouldInstallPluginsAndDependenciesTransitive() throws URISyntaxException {
+ goOffline.setEasyantResolverName(EASYANT_BUILDSCOPE_REP);
+ goOffline.setProjectResolverName(PROJECT_BUILDSCOPE_REP);
+ goOffline.setModuleIvy(new File(this.getClass().getResource("dependencies/module.ivy").toURI()));
+ goOffline.execute();
+
+ assertLogContaining("installing mycompany#simpleplugin;0.1");
+ assertLogContaining("installing junit#junit;4.4");
+ assertLogContaining("installing org.mortbay.jetty#jetty;6.1.14");
+
+ assertFileExists(easyantBuildScopeRepoFolder,"/mycompany/simpleplugin/0.1/ivy.xml");
+ assertFileExists(easyantBuildScopeRepoFolder,"/mycompany/simpleplugin/0.1/simpleplugin.ant");
+
+ assertFileExists(projectBuildScopeRepoFolder, "/junit/junit/4.4/junit.jar");
+ assertFileExists(projectBuildScopeRepoFolder, "/org.mortbay.jetty/jetty/6.1.14/jetty.jar");
+ assertFileExists(projectBuildScopeRepoFolder, "/org.mortbay.jetty/jetty-util/6.1.14/jetty-util.jar");
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/ant-easyant-core/blob/c61c43ee/src/test/resources/ivysettings-test.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/ivysettings-test.xml b/src/test/resources/ivysettings-test.xml
index 2ae65c9..21e1c83 100644
--- a/src/test/resources/ivysettings-test.xml
+++ b/src/test/resources/ivysettings-test.xml
@@ -16,7 +16,7 @@
-->
<ivysettings>
<property name="apache.easyant.public.url" value="http://repository.easyant.org/apache-easyant"/>
- <property name="easyant.default.cache.dir" value="${basedir}/easyant-cache-test"/>
+ <property name="easyant.default.cache.dir" value="${basedir}/easyant-cache-test" override="false"/>
<settings defaultResolver="easyant-test-chain"/>
<caches defaultCacheDir="${easyant.default.cache.dir}" useOrigin="true" />
http://git-wip-us.apache.org/repos/asf/ant-easyant-core/blob/c61c43ee/src/test/resources/org/apache/easyant/tasks/dependencies/module.ivy
----------------------------------------------------------------------
diff --git a/src/test/resources/org/apache/easyant/tasks/dependencies/module.ivy b/src/test/resources/org/apache/easyant/tasks/dependencies/module.ivy
new file mode 100644
index 0000000..f5af106
--- /dev/null
+++ b/src/test/resources/org/apache/easyant/tasks/dependencies/module.ivy
@@ -0,0 +1,33 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ivy-module version="2.0" xmlns:ea="http://www.easyant.org">
+ <info organisation="org.apache.easyant" module="standard-java-app" status="integration" revision="1.0" >
+ <ea:build org="mycompany" module="simpleplugin" revision="0.1">
+ <ea:property name="run.main.classname" value="org.apache.easyant.example.Example"/>
+ <ea:plugin org="mycompany" module="simplepluginwithproperties" revision="0.1"/>
+ </ea:build>
+ </info>
+ <configurations>
+ <conf name="default" visibility="public" description="runtime dependencies and master artifact can be used with this conf"/>
+ <conf name="test" visibility="private" description="this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases."/>
+ </configurations>
+ <dependencies>
+ <dependency org="junit" name="junit" rev="4.4" />
+ <!-- Add a dependency with transitive dependencies -->
+ <dependency org="org.mortbay.jetty" name="jetty" rev="6.1.14" />
+ </dependencies>
+</ivy-module>