zDev - M2E - OSS
  1. zDev - M2E - OSS
  2. MNGECLIPSE-676

JVM always uses target/classes instead of configured output folder

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 0.9.4
    • Fix Version/s: None
    • Component/s: Project Configuration
    • Labels:
      None
    • Global Rank:
      1404

      Description

      In m2Eclipse 0.9.4 the classpath the JVM uses is always the target/classes folder instead of the specific output folder for the project.

      I have looked at:
      http://docs.codehaus.org/display/M2ECLIPSE/Separate+Eclipse+and+Maven+output+folders
      and
      http://markmail.org/message/733lqtw5moa4cim4

      I see that "As of version 0.9.4 plugin is always using the same output folders as Maven"

      I don't see a way to change m2eclipse to allow a different output folder than what is configured in Maven.

      Please add this feature to maintain backward compatibility to previous release of the m2Eclipse plug-in.

        Issue Links

          Activity

          Hide
          Carlus Henry added a comment -

          I was also running into this issue, and later discovered that it was because I was using m2eclipse and a proprietary Ant based framework for building the application. When I built the application using the proprietary framework, it would compile the classes into the same location that Eclipse was compiling the classes. After some digging, I realized that there is a way to change the location where m2eclipse / maven will send the compiled classes. After making the change, I do not have these problems anymore.

          In order to change where Maven is sending the compiled java files, modify you pom to include something like this:
          ...
          <build>
          ...
          <outputDirectory>$

          {location where "src" classes should reside}

          </outputDirectory>
          <testOutputDirectory>$

          {location where "test" classes should reside}

          </testOutputDirectory>
          ...
          </build>
          ....

          This will not only change where maven compiles classes, but it will also change where Eclipse is compiling classes through the m2eclipse plugin - since it is using the pom.xml file to base the project configuration.

          The other option, of course, is to change the location where the 3rd party tool is compiling your classes.

          Note: Unfortunately, this resolution will not help you if you are using Maven from the command line - since both eclipse and maven are going to use the pom.xml file as to where the project should compile it's classes.

          Show
          Carlus Henry added a comment - I was also running into this issue, and later discovered that it was because I was using m2eclipse and a proprietary Ant based framework for building the application. When I built the application using the proprietary framework, it would compile the classes into the same location that Eclipse was compiling the classes. After some digging, I realized that there is a way to change the location where m2eclipse / maven will send the compiled classes. After making the change, I do not have these problems anymore. In order to change where Maven is sending the compiled java files, modify you pom to include something like this: ... <build> ... <outputDirectory>$ {location where "src" classes should reside} </outputDirectory> <testOutputDirectory>$ {location where "test" classes should reside} </testOutputDirectory> ... </build> .... This will not only change where maven compiles classes, but it will also change where Eclipse is compiling classes through the m2eclipse plugin - since it is using the pom.xml file to base the project configuration. The other option, of course, is to change the location where the 3rd party tool is compiling your classes. Note: Unfortunately, this resolution will not help you if you are using Maven from the command line - since both eclipse and maven are going to use the pom.xml file as to where the project should compile it's classes.
          Hide
          dvoytenko added a comment -

          Going through these comments I'm still not quite sure why not just use folders explicitly configured in Eclipse as output folders for launch configs? That seems like a rather natural solution. I.e. by default folks could just use configured target/classes and target/test-classes or change them in the Build Config if necessary.

          Show
          dvoytenko added a comment - Going through these comments I'm still not quite sure why not just use folders explicitly configured in Eclipse as output folders for launch configs? That seems like a rather natural solution. I.e. by default folks could just use configured target/classes and target/test-classes or change them in the Build Config if necessary.
          Hide
          dvoytenko added a comment -

          Or at least, would it be possible to allow customization of active maven profile for the whole eclipse workspace, not each project separately?

          Show
          dvoytenko added a comment - Or at least, would it be possible to allow customization of active maven profile for the whole eclipse workspace, not each project separately?
          Hide
          Eugene Kuleshov added a comment -

          Dmitri, this issue is mostly about output folders for the project configuration. The runtime classpath used for various launch configuration is a separate story and in case of Maven that classpath is only remotely related to the comple-time classpath.

          For switcing profiles, you could try to use profile activation rules based on system properties and specify those properies in your eclipse.ini or launch shortcut. If you need separate workspace setting for activating Maven profile, please submit a separate enhancement request.

          Show
          Eugene Kuleshov added a comment - Dmitri, this issue is mostly about output folders for the project configuration. The runtime classpath used for various launch configuration is a separate story and in case of Maven that classpath is only remotely related to the comple-time classpath. For switcing profiles, you could try to use profile activation rules based on system properties and specify those properies in your eclipse.ini or launch shortcut. If you need separate workspace setting for activating Maven profile, please submit a separate enhancement request.
          Hide
          frickeo added a comment -

          Hello everybody,

          another scenario that shows how important it is to be able to configure seperate output folders are web applications.

          Whenever I develope web apps or portlets, I use the exploded mode of tomcat for testing. In this setup, I have a context file in conf/Catalina/localhost that defines the docbase. And I have configured the output path of my eclipse project to be "docroot/WEB-INF/classes". That means, I only have to make my changes, save them and refresh the browser. If the debugger is running, I can see my changes immediately.

          For the maven side I am using the maven-war-plugin to put everything into the target folder.

          With this setup, I cannot use m2eclipse without seperated class folder. If I would tell maven to use docroot/WEB-INF/classes as output folder, a 'mvn clean' would shredder my webapp! If I stay with seperate classfolders, I cannot use the m2eclipse dependency management, because no test will run any longer in eclipse. Running "Maven / Update project configuration" will change my project setup in such a way, that the classes are stored outside of my web app.

          Is it possible to add a configuration switch to m2eclipse, that prepends the output folders configured in the .classpath file to the Maven Dependency Container?

          Show
          frickeo added a comment - Hello everybody, another scenario that shows how important it is to be able to configure seperate output folders are web applications. Whenever I develope web apps or portlets, I use the exploded mode of tomcat for testing. In this setup, I have a context file in conf/Catalina/localhost that defines the docbase. And I have configured the output path of my eclipse project to be "docroot/WEB-INF/classes". That means, I only have to make my changes, save them and refresh the browser. If the debugger is running, I can see my changes immediately. For the maven side I am using the maven-war-plugin to put everything into the target folder. With this setup, I cannot use m2eclipse without seperated class folder. If I would tell maven to use docroot/WEB-INF/classes as output folder, a 'mvn clean' would shredder my webapp! If I stay with seperate classfolders, I cannot use the m2eclipse dependency management, because no test will run any longer in eclipse. Running "Maven / Update project configuration" will change my project setup in such a way, that the classes are stored outside of my web app. Is it possible to add a configuration switch to m2eclipse, that prepends the output folders configured in the .classpath file to the Maven Dependency Container?

            People

            • Assignee:
              Unassigned
              Reporter:
              Deleted User
              Last Updated By:
              Brian Fox
            • Votes:
              5 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Date of First Response: