Maven Integration for Eclipse

Output folders are not set correctly by 'Update Sources' action

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.0.3
  • Fix Version/s: 0.0.4
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    1

Description

Although source folders on build path are updated correctly by 'Update Sources' action,
output folders are not updated at all.

For example, it is expected that output folder for 'src/test/java' and 'src/test/resources'
is set to 'target/test-classes', but not set.

Activity

Hide
Eugene Kuleshov added a comment -

Actually it is trickier then it seems. You can't really use the same output folders between Eclipse compiler and any external tools, including Maven build. So, it is generally a bad idea to use the same output folders.

See discussion about this at https://bugs.eclipse.org/bugs/show_bug.cgi?id=99497

Show
Eugene Kuleshov added a comment - Actually it is trickier then it seems. You can't really use the same output folders between Eclipse compiler and any external tools, including Maven build. So, it is generally a bad idea to use the same output folders. See discussion about this at https://bugs.eclipse.org/bugs/show_bug.cgi?id=99497
Hide
YOKOTA Takehiko added a comment -

I understand what you want to say. Output folder may not be shared
by Eclipse and others. But what I'd like to say more is an inconvenient
behavior that 'Update Source Folders' action completely deletes
all custom output folder settings.

For instance, src/main/resources/log4j.properties and
src/test/resources/log4j.properties (for testing) are conflicted
by being copied into single output folder. So, I hope alternative function
to specify output folders for main resources and test resources respectively
on each subproject.

Show
YOKOTA Takehiko added a comment - I understand what you want to say. Output folder may not be shared by Eclipse and others. But what I'd like to say more is an inconvenient behavior that 'Update Source Folders' action completely deletes all custom output folder settings. For instance, src/main/resources/log4j.properties and src/test/resources/log4j.properties (for testing) are conflicted by being copied into single output folder. So, I hope alternative function to specify output folders for main resources and test resources respectively on each subproject.
Hide
Eugene Kuleshov added a comment -

I am not sure how they can't conflict even when going under separate folders? They will end up in the same classpath anyways. Am I missing something?

Another thing is that action "Update Source Folders" intended to free you from worying about what source and target folders should be, as long as you have correct definitions in Maven's POM. we are open for suggestions how to improve it and keep it simple at the same time.

Show
Eugene Kuleshov added a comment - I am not sure how they can't conflict even when going under separate folders? They will end up in the same classpath anyways. Am I missing something? Another thing is that action "Update Source Folders" intended to free you from worying about what source and target folders should be, as long as you have correct definitions in Maven's POM. we are open for suggestions how to improve it and keep it simple at the same time.
Hide
YOKOTA Takehiko added a comment -

Sorry, I noticed that the example was wrong. What I meant was I didn't
want to gather resources of all subprojects into single output folder.

As you said, main resource and test resource will gather into the same classpath
at certain subproject, but I think that some resources of subproject-A
and independent subproject-B's one should not be gathered into
single classpath. How about this?

So I'd like to separate output folders per subproject, but currently
I have no idea for realize this.

Show
YOKOTA Takehiko added a comment - Sorry, I noticed that the example was wrong. What I meant was I didn't want to gather resources of all subprojects into single output folder. As you said, main resource and test resource will gather into the same classpath at certain subproject, but I think that some resources of subproject-A and independent subproject-B's one should not be gathered into single classpath. How about this? So I'd like to separate output folders per subproject, but currently I have no idea for realize this.
Hide
Eugene Kuleshov added a comment -

Let's try to look at this from a different angle. why would you need these resources anyways? I can only think that they could be needed to run unit tests. However wWhen you run these tests from Maven resources already taken from the right folders. So, we may just add some support for JUnit runner within Eclipse that will use right resource folders when needed.

Show
Eugene Kuleshov added a comment - Let's try to look at this from a different angle. why would you need these resources anyways? I can only think that they could be needed to run unit tests. However wWhen you run these tests from Maven resources already taken from the right folders. So, we may just add some support for JUnit runner within Eclipse that will use right resource folders when needed.
Hide
YOKOTA Takehiko added a comment -

I tried to create a patch for this issue. This patch enables
to separate output folders per subprojects.

It adds a boolean property 'Separate Output Folders'
at 'Maven2 Preferences' dialog, and after turning on this
property, 'Update Source Folders' action creates source
path entries with individual output folder.

In detail, please picture the following project:
project/pom.xml
subproject1/pom.xml
src/main/java
src/main/resources
src/test/java
src/test/resources
subproject2/pom.xml
src/main/java
src/main/resources
src/test/java
src/test/resources
and assume that the default output folder is 'project/bin'.

After invoking 'Update Source Folders' action, source
folders on build path becomes like following:
project/subproject1/src/main/java
Output folder: project/subproject1/bin
project/subproject1/src/main/resources
Output folder: project/subproject1/bin
project/subproject1/src/test/java
Output folder: project/subproject1/bin
project/subproject1/src/test/resources
Output folder: project/subproject1/bin

project/subproject2/src/main/java
Output folder: project/subproject2/bin
project/subproject2/src/main/resources
Output folder: project/subproject2/bin
project/subproject2/src/test/java
Output folder: project/subproject2/bin
project/subproject2/src/test/resources
Output folder: project/subproject2/bin

In this patch, project-relative path of the default output folder
('bin') is used to generate each subproject's output folder.

I hope you accept this patch.

Show
YOKOTA Takehiko added a comment - I tried to create a patch for this issue. This patch enables to separate output folders per subprojects. It adds a boolean property 'Separate Output Folders' at 'Maven2 Preferences' dialog, and after turning on this property, 'Update Source Folders' action creates source path entries with individual output folder. In detail, please picture the following project: project/pom.xml subproject1/pom.xml src/main/java src/main/resources src/test/java src/test/resources subproject2/pom.xml src/main/java src/main/resources src/test/java src/test/resources and assume that the default output folder is 'project/bin'. After invoking 'Update Source Folders' action, source folders on build path becomes like following: project/subproject1/src/main/java Output folder: project/subproject1/bin project/subproject1/src/main/resources Output folder: project/subproject1/bin project/subproject1/src/test/java Output folder: project/subproject1/bin project/subproject1/src/test/resources Output folder: project/subproject1/bin project/subproject2/src/main/java Output folder: project/subproject2/bin project/subproject2/src/main/resources Output folder: project/subproject2/bin project/subproject2/src/test/java Output folder: project/subproject2/bin project/subproject2/src/test/resources Output folder: project/subproject2/bin In this patch, project-relative path of the default output folder ('bin') is used to generate each subproject's output folder. I hope you accept this patch.
Hide
Eugene Kuleshov added a comment -

Takehiko, can you please respond to my comment about there separate resources would be needed? I am still not sure if it will be a good idea to have two parallel trees for Maven and Eclipse targets, especially when they all going into the same build and classpath.

As a side note, when resources are placed in a separate folder we may use resource folder as an output folder for Eclipse, so it won't even need to copy anything.

Show
Eugene Kuleshov added a comment - Takehiko, can you please respond to my comment about there separate resources would be needed? I am still not sure if it will be a good idea to have two parallel trees for Maven and Eclipse targets, especially when they all going into the same build and classpath. As a side note, when resources are placed in a separate folder we may use resource folder as an output folder for Eclipse, so it won't even need to copy anything.
Hide
YOKOTA Takehiko added a comment -

In fact, my strongest motivation to separate output folders per subprojects is to suppress Eclipse's warning messages about conflict of resources by copying into single output folder. So it may not be critical issue not to separate output folder, but lots of meaningless warning messages disturb development because they jam other important error messages up.

> As a side note, when resources are placed in a separate folder we may use
> resource folder as an output folder for Eclipse, so it won't even need to copy
> anything.

I'm sorry but I could not see what you meant. Could you please explain "use resource folder as an output folder for Eclipse" in detail?

Show
YOKOTA Takehiko added a comment - In fact, my strongest motivation to separate output folders per subprojects is to suppress Eclipse's warning messages about conflict of resources by copying into single output folder. So it may not be critical issue not to separate output folder, but lots of meaningless warning messages disturb development because they jam other important error messages up. > As a side note, when resources are placed in a separate folder we may use > resource folder as an output folder for Eclipse, so it won't even need to copy > anything. I'm sorry but I could not see what you meant. Could you please explain "use resource folder as an output folder for Eclipse" in detail?
Hide
Eugene Kuleshov added a comment -

It seems to me that Eclipse is actually rignt and you should have these properties files in a single place (perhaps common project for all subprojects), thoug I have to check some details on how Maven prepare classpath.

What I meant about target build path for resources is that you can point output folder to the same folder where sources are.

Show
Eugene Kuleshov added a comment - It seems to me that Eclipse is actually rignt and you should have these properties files in a single place (perhaps common project for all subprojects), thoug I have to check some details on how Maven prepare classpath. What I meant about target build path for resources is that you can point output folder to the same folder where sources are.
Hide
YOKOTA Takehiko added a comment -

You may be right about resources for actual code, but how about resources
for testing? For example, assume that each subproject has log4j.properties
in src/test/resources folder and those contents are different from others.
I have no idea about a way to put those files in a single place.

About target build path, even if I set output folder to the same folder as source
one, the setting will be deleted after invoking 'Update Source Folder' action. X-<

Show
YOKOTA Takehiko added a comment - You may be right about resources for actual code, but how about resources for testing? For example, assume that each subproject has log4j.properties in src/test/resources folder and those contents are different from others. I have no idea about a way to put those files in a single place. About target build path, even if I set output folder to the same folder as source one, the setting will be deleted after invoking 'Update Source Folder' action. X-<
Hide
Eugene Kuleshov added a comment -

Lets forget how this feature implemented now. I am just trying to understand what is the best way and still don't see how we can make it work for single project when all resources are going into the same classpath,

Show
Eugene Kuleshov added a comment - Lets forget how this feature implemented now. I am just trying to understand what is the best way and still don't see how we can make it work for single project when all resources are going into the same classpath,
Hide
Eugene Kuleshov added a comment -

This action now setting output folders for resource folders to themselves. This eliminates warnings about resource conflicts even without adding property to use separate output folders. All source code still going to be compiled into single location.

Show
Eugene Kuleshov added a comment - This action now setting output folders for resource folders to themselves. This eliminates warnings about resource conflicts even without adding property to use separate output folders. All source code still going to be compiled into single location.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: