Uploaded image for project: 'Ivy'
  1. Ivy
  2. IVY-124

Excluding the root project from the buildlist

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • unspecified
    • 1.3-RC1
    • Core
    • None
    • This patch should work on all environments.

    Description

      I like to set up my project build to take different actions on the project's dependencies from the project itself. In other words, I don't want to subant on a union of all of the project's dependencies and the project itself. So for example:

      project-1 is standalone
      project-2 is standalone
      project-3 depends on project-1 and project-2

      ... now returns

      {project-1,project-2,project-3}

      . I want it to return

      {project-1,project-2}

      .

      The patch below provides this functionality. It defines an attribute called "excluderoot" on the buildlist tag and must be used in conjunction with the "root" attribute. "excluderoot" defaults to false. Continuing the example above,

      <ivy:buildlist reference="my-buildlist" root="project-3" excluderoot="true">...</ivy:buildlist>

      will now make sure my-buildlist only contains matches from project-1 and project-2.

      Index: ivy/test/java/fr/jayasoft/ivy/ant/IvyBuildListTest.java
      ===================================================================
      — ivy/test/java/fr/jayasoft/ivy/ant/IvyBuildListTest.java (revision 107)
      +++ ivy/test/java/fr/jayasoft/ivy/ant/IvyBuildListTest.java (working copy)
      @@ -103,4 +103,33 @@
      assertEquals(new File("test/buildlist/C/build.xml").getAbsolutePath(), new File(files[1]).getAbsolutePath());
      }

      + public void testFilteredExcludeRootBuildList()

      { + Project p = new Project(); + + IvyBuildList buildlist = new IvyBuildList(); + buildlist.setProject(p); + buildlist.setRoot("C"); + buildlist.setExcludeRoot(true); + + FileSet fs = new FileSet(); + fs.setDir(new File("test/buildlist")); + fs.setIncludes("**/build.xml"); + buildlist.addFileset(fs); + + buildlist.setReference("ordered.build.files"); + + buildlist.execute(); + + Object o = p.getReference("ordered.build.files"); + assertNotNull(o); + assertTrue(o instanceof Path); + + Path path = (Path)o; + String[] files = path.list(); + assertNotNull(files); + assertEquals(1, files.length); // A and C should be filtered out + + assertEquals(new File("test/buildlist/B/build.xml").getAbsolutePath(), new File(files[0]).getAbsolutePath()); + }

      +
      }
      Index: ivy/src/java/fr/jayasoft/ivy/ant/IvyBuildList.java
      ===================================================================
      — ivy/src/java/fr/jayasoft/ivy/ant/IvyBuildList.java (revision 107)
      +++ ivy/src/java/fr/jayasoft/ivy/ant/IvyBuildList.java (working copy)
      @@ -38,6 +38,7 @@
      private boolean _reverse = false;
      private String _ivyFilePath;
      private String _root = "*";
      + private boolean _excludeRoot = false;

      public void addFileset(FileSet buildFiles)

      { @@ -60,6 +61,14 @@ _root = root; }

      + public boolean isExcludeRoot()

      { + return _excludeRoot; + }

      +
      + public void setExcludeRoot(boolean root)

      { + _excludeRoot = root; + }

      +
      public void execute() throws BuildException {
      if (_reference == null) {
      throw new BuildException("reference should be provided in ivy build list");
      @@ -161,6 +170,12 @@
      Set toKeep = new HashSet();
      processFilterNode(rootmd, toKeep, moduleIdMap);

      + // With the excluderoot attribute set to true, take the rootmd out of the toKeep set.
      + if (_excludeRoot)

      { + Message.verbose("Excluded module " + rootmd.getModuleRevisionId().getModuleId().getName()); + toKeep.remove(rootmd); + }

      +
      // just for logging
      for (Iterator iter = toKeep.iterator(); iter.hasNext()

      { ModuleDescriptor md = ((ModuleDescriptor) iter.next()); @@ -236,5 +251,4 @@ _reverse = reverse; }

      -
      }

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--excluderoot.patch
          3 kB
          Constantine Vetoshev

        Activity

          People

            xavier Xavier Hanin
            gepard Constantine Vetoshev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: