Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Not an issue
    • Affects Version/s: None
    • Fix Version/s: 3.4
    • Component/s: None
    • Labels:
      None
    • Environment:

      maven 2.0.4, jdk 1.5

      Description

      Modified version of andromda-all/maven/2/multi-source/src/main/java/org/andromda/maven/plugin/MultiSourceMojo.java follows (as I can not see an other way of attaching it). It adds to current implementation a possibility for additional test source paths. Usage is similar to existing one. In addition or instead of the <sourceDirectories> tag you use <testSourceDirectories> tag in plugin configuration.
      I have tested it with maven 2.0.4 and jdk 1.5.
      It would be fine if this or similar patch could be applied on the 3.3-SNAPSHOT branch and newer.

      ----------------------------- MultiSourceMojo.java -----------------------------------
      package org.andromda.maven.plugin.multisource;

      import java.util.Iterator;
      import java.util.List;

      import org.andromda.core.common.ResourceUtils;
      import org.apache.commons.lang.ObjectUtils;
      import org.apache.maven.plugin.AbstractMojo;
      import org.apache.maven.plugin.MojoExecutionException;
      import org.apache.maven.plugin.MojoFailureException;
      import org.apache.maven.project.MavenProject;

      /**

      • A Mojo who's sole purpose is to allow multiple source roots
      • to be added to the project (since the Maven Compiler Plugin
      • doesn't allow it), this plugin should be removed if they
      • allow it in the future.
        *
      • @author Chad Brandon
      • @goal add-source
      • @phase generate-sources
        */
        public class MultiSourceMojo
        extends AbstractMojo
        {
        /**
      • The source directories containing the sources to be compiled.
        *
      • @parameter
      • @required
        */
        private List sourceDirectories;

      /**

      • The test source directories containing the sources to be compiled for test.
        *
      • @parameter
      • @required
        */
        private List testSourceDirectories;

      /**

      • The maven project.
        *
      • @parameter expression="$ {project}

        "

      • @required
      • @readonly
      • @description "the maven project to use"
        */
        private MavenProject project;

      /**

      • @see org.apache.maven.plugin.Mojo#execute()
        */
        public void execute()
        throws MojoExecutionException, MojoFailureException { String baseDirectory = ResourceUtils.normalizePath(ObjectUtils.toString(project.getBasedir()) + '/'); addNormalizedPaths( this.sourceDirectories, this.project.getCompileSourceRoots(), baseDirectory ); addNormalizedPaths( this.testSourceDirectories, this.project.getTestCompileSourceRoots(), baseDirectory ); }

      private void addNormalizedPaths( List fromPaths, List toPaths, String baseDirectory )
      {
      for (final Iterator iterator = fromPaths.iterator(); iterator.hasNext()
      {
      String path = ResourceUtils.normalizePath((String)iterator.next());
      if (!path.startsWith(baseDirectory))

      { path = ResourceUtils.normalizePath(baseDirectory + path); }

      toPaths.add(path);
      }
      }
      }

        Attachments

          Activity

            People

            • Assignee:
              overheat overheat
              Reporter:
              pawel.matras@computas.no Pawel Matras
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: