Maven 1.x Eclipse Plugin
  1. Maven 1.x Eclipse Plugin
  2. MPECLIPSE-72

Failing use cases for projects with just resources

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.10
    • Fix Version/s: 1.10
    • Labels:
      None
    • Number of attachments :
      3

      Description

      I've just upgraded to v1.10-SNAPSHOT as I'm looking at adding some new features, and I have a few issues with some usecases / project structures I use. Most of these issues arise from projects where there is no java source code in the source directory. As the issues are so inter related and affect simialr lines in the script, I decided to put them into the same issue and the patch contains all of them.

      Part1: MPECLIPSE-56 introduced checks to only generate .classpath and add the java nature if $

      {sourcesPresent}. I can see why this has been added, however, I feel its too restrictive. I feel a more suitable check would be based on the presence of the source or the resources, i.e. ${sourcesPresent or !pom.build.resources.isEmpty()}. This also affects the resources.addtoclasspath feature as its wrapped by a <j:if test="${sourcesPresent}

      "> which is not needed around it. I've moved the block of script to after the test.

      Part2: The resources.addtoclasspath feature works very nicely, however, I seemed to be having issues with eclipse due to the separator always being appended to the end of the includes/excludes. Its pretty simple to change this to intelligently add the separator,
      e.g. for includeAsString:
      <j:set var="includingAsString" value="" />
      <j:forEach var="res" items="$

      {resource.includes}

      ">
      <j:if test="$

      {includingAsString.length() > 0}

      ">
      <j:set var="includingAsString" value="$

      {includingAsString}|" />
      </j:if>
      <j:set var="includingAsString" value="${includingAsString}

      $

      {res}

      " />
      </j:forEach>

      Part3: The resources.addtoclasspath always adds the directory as a source classpathentry. Quite often, parent project.xml files include something like src/main/resources, and if this is not used by the sub project, then eclipse is generating an error saying it cannot find the path specified. A simple fix to this is just to check for the presence of the directory. I added this around the comment about dupplicates.

      <maven:makeRelativePath var="resourceDirectory" basedir="$

      {basedir}

      " path="$

      {resource.directory}

      " separator="/"/>
      <u:file var="resourceDirectoryFile" name="$

      {resourceDirectory}"/>
      <!-- don't add duplicate directories -->
      <j:if test="${resourceDirectoryFile.exists() and !resourceDirectory.equals(srcDir) and (!resourceDirectory.equals(testSrcDir) or !unitTestSourcesPresent)}">
      <classpathentry kind="src" path="${resourceDirectory}

      " including="$

      {includingAsString}

      " excluding="$

      {excludingAsString}

      " />
      </j:if>

      I'll attach the patch shortly, I've run the tests and my changes pass.

        Activity

        Hide
        Kristopher Brown added a comment -

        Diff for changes outlined.

        Show
        Kristopher Brown added a comment - Diff for changes outlined.
        Hide
        Kristopher Brown added a comment -

        A new test to add to the plugin, which fails under the current code base, and passes under the proposed changes.

        Show
        Kristopher Brown added a comment - A new test to add to the plugin, which fails under the current code base, and passes under the proposed changes.
        Hide
        Kristopher Brown added a comment -

        Oops, seems I didn't test it quite right. The line

        <u:file var="resourceDirectoryFile" name="$

        {resourceDirectory}

        "/>

        is incorrect and should be

        <u:file var="resourceDirectoryFile" name="$

        {resource.directory}

        "/>

        I'll update the diff to reflect that.

        Also, note that the maintest fails under the changes proposed. This is due to it having 2 resources [src/resources and src/test-resources] whose directories do not exist. It is suitable to either change the test to expect 4 rather than 6 or add a directory for each and place a dir.txt in them.

        Show
        Kristopher Brown added a comment - Oops, seems I didn't test it quite right. The line <u:file var="resourceDirectoryFile" name="$ {resourceDirectory} "/> is incorrect and should be <u:file var="resourceDirectoryFile" name="$ {resource.directory} "/> I'll update the diff to reflect that. Also, note that the maintest fails under the changes proposed. This is due to it having 2 resources [src/resources and src/test-resources] whose directories do not exist. It is suitable to either change the test to expect 4 rather than 6 or add a directory for each and place a dir.txt in them.
        Hide
        Kristopher Brown added a comment -

        latest version

        Show
        Kristopher Brown added a comment - latest version
        Hide
        fabrizio giustina added a comment -

        patch committed to svn for 1.10, thanks

        Show
        fabrizio giustina added a comment - patch committed to svn for 1.10, thanks

          People

          • Assignee:
            fabrizio giustina
            Reporter:
            Kristopher Brown
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: