Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 0.0.5
-
Fix Version/s: 0.0.10
-
Component/s: None
-
Labels:None
-
Environment:Linux. JDK 1.5. XmlBeans 2.x.
Description
I have a problem with Maven2, XmlBeans Maven Plugin and this plugin (Eclipse Maven Plugin). However, I do believe that the problem will exist when generating sources in other ways as well. I assume that you are familiar with XmlBeans (if not, it's Java Binding tools that creates Java classes for an XML Schema).
In my project I use XmlBeans when performing unit tests. Hence, the XmlBeans Maven Plugin generates Java code under /target/test-xmlbeans-source. The actual problem is that Eclipse needs the generated Java code otherwise it generates errors since it can't find the classes used by the unit tests. I want the Maven plugin to add classes of auto-generated source code to Eclipse class paths (dependency). Is there a solution for this?
Like I hinted above this is not a XmlBeans specific problem as a project can have other tools generating code using e.g. XSLT, AntLR etc (my project uses XSLT as well). There are many advantages using Maven and two important ones are with it and Eclipse:
1) the project is built the same (i.e. using the exact same setup of libraries, library versions etc) whether is it inside or outside Eclipse
2) all developers have the exact same setup (same version of dependencies etc)
Are there any other known (potential) issues preventing Eclipse and Maven from working seamlessly?
Can the Eclipses built-in compiler cause problems?
-
- MNGECLIPSE-75.tar.gz
- 15/Feb/06 10:01 AM
- 0.8 kB
- Jochen Wiedmann
-
Hide
- mngeclipse-75-xmlbeans-testcase.zip
- 16/Feb/06 9:41 AM
- 4 kB
- Jimisola Laursen
-
- mngeclipse-75-xmlbeans-testcase/pom.xml 3 kB
- mngeclipse-75-xmlbeans-testcase/.../ValidateXmlBeansProblemTest.java 0.3 kB
- mngeclipse-75-xmlbeans-testcase/.../test.xsd 0.5 kB
- mngeclipse-75-xmlbeans-testcase/.../test.xsdconfig 0.4 kB
-
- set-output-folder.patch
- 09/Mar/06 12:55 AM
- 10 kB
- Ray Tsang
-
- set-output-folder.patch
- 07/Mar/06 9:50 PM
- 4 kB
- Ray Tsang
Activity
No change. At least not a successful one. What is "Update Source Folders" suppose to do exactly (as I would like to verify it)?
The generated source files lays under /target/test-xmlbeans-source, not under src/ - is that causing a problem?
I haven't managed to get XmlBeans to compile the class files either, so I have do check with the XmlBeans plugin as well.
Let me clearify myself, when I asked about "Update Source Folders" I know that it is suppose to include the generated sources into the classpath. Should I see this under "Maven2 Dependencies"? I can't see it there on in the Project's Java Build Path.
Basically what that action does it runs "generate sources" build phase and adds source folders registered by plugins to the list of the source folders. You should see what is happening on M2 Console.
As I said, if it does not work as expected, then attach sample project that would allow to reproduce this issue.
The attached file contains a small project, which doesn't use a source code generator. Nevertheless, the "Update source folders" action doesn't seem to work.
Interesting glitch... You seem to have output folder pointing to the project root and you can actually see warning about that on M2 console. Once I changed default output to a sub folder (e.g. MNGECLIPSE-75/target/eclipse) update sources completed fine.
I understand that there is an easy workaround. However, my settings have been the default settings of any Eclipse project. In other words, I am forced to manually configure the classpath for a new project before using "Update source folders". I'd still consider that a bug.
I am not saying that it won't be fixed. But it would be nice if you can confirm that your XmlBeans stuff is getting properly into the sources once target folder is set properly.
Example project to illustrate the problem with the plugin not including the generated source.
Note that I am not sure that this setup is correct. It could be an XmlBean plugin issue.
XmlBeans in configured to generate source code, i.e. .java files, under target. Perhaps it needs to generate class files for the plugin to work?
Maven console output:
[jimisola@turing mngeclipse-75-xmlbeans-testcase]$ mvn clean:clean && mvn test-compile
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'clean'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building MNGECLIPSE #75 XMlBeans Testcase
[INFO] task-segment: [clean:clean]
[INFO] ----------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] ----------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Feb 16 16:40:28 CET 2006
[INFO] Final Memory: 2M/4M
[INFO] ----------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building MNGECLIPSE #75 XMlBeans Testcase
[INFO] task-segment: [test-compile]
[INFO] ----------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[WARNING]
Artifact junit:junit:jar:3.8.1 retains local scope 'test' overriding broader scope 'compile'
given by a dependency. If this is not intended, modify or remove the local scope.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [xmlbeans:xmlbeans-test {execution: default}]
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
Compiling 1 source file to /home/jimisola/p4clients/lf/iso/main/mngeclipse-75-xmlbeans-testcase/target/test-classes
[INFO] ----------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Thu Feb 16 16:40:35 CET 2006
[INFO] Final Memory: 4M/10M
[INFO] ----------------------------------------------------------------------------
This is not the exact same problem, but in another project we generate source code using XSLT. Where should this source file be place (we don't want them under our other "real" java files) in order to work with console maven and the Eclipse Maven Plugin?
I am thinking:
src/autogen
in addition to
src/main
src/test
You didn't answer my question regarding your first test project.
Please don't mix things up and take one step at a time. You don't have to use mvn command line in order to get source folders un Eclipse. All you need is to use "Update Sources" action and the console i was referring to is M2 Console that you can open in a standard Eclipse console view.
Also note that adding generatd stuff under anything byt target folder is really bad idea.
Also, it seems that your xmlbeans project is generating sources for tests only. Plugin is currently not executing generate-test-sources and generate-test-resources goals.
You can verify that by trying to use xmlbeans goal. So, please fill in another jira for this issue.
By the way, I wonder if we should use process* goals instead of generate*...
Eugene,
- In respone to your first 2nd last comment:
The first test project was not mine - it was Jochen's. Two different persons, but with similar problems.
I know that I don't need to run mvn from (shell) console for get source folders in Eclipse. The reason that I did is that I wanted to attach you its output in order for you to see that it works outside of Eclipse. The problem still exists as far as I am concerned. That is, even if I generate the sources from outside (with mvn) they are not pickup by Eclipse when I use "Update Sources".
src/test/java/ValidateXmlBeansProblemTest.java: "TestDocument cannot be resolved to a Type"
the problem is not only that generation as you mention in the last comment, but the fact that the plugin does not seem to make Eclipse aware of the generated source code
- In respone to your last comment:
I am very new to Maven and even if I am aware of the different goals and their order I don't follow you on how I should verify it by trying to use the xmlbeans goal. How do I do this?
I'll file a bug, but I would like to know how to verify as well. Plugin does not execute generate-test-sources and generate-test-resources-goals"?
Last, I am usually very concerned about names but "process" or "generate" does not matter as long as it works
(who is "we" btw?)
- In respone to your first 2nd last comment:
- In respone to your last comment:
Jimsola, I really prefer to track these two issues separately. Please create new one for your stuff and I'll comment there.
Hmm.. I must have missed out it then (non of your last comments has any question marks btw). What question are you awaiting an answer to?
Don't forget that you have two different users commenting on this issue. Are you refering two this comment:
"I am not saying that it won't be fixed. But it would be nice if you can confirm that your XmlBeans stuff is getting properly into the sources once target folder is set properly."
If so, then that was a comment to Jochen's attachment and his project. Hi did not use XmlBeans - that was me.
If the above was your question, then here is my answer:
1. "Update Sources" did not add target/test-xmlbeans-source with default output folder (MNGECLIPSE-75-XMLBEANS)
2. "Update Sources" did not add target/test-xmlbeans-source with output folder changed to MNGECLIPSE-75-XMLBEANS/target/eclipse
How is the Eclipse Maven Plugin and Eclipse suppose to co-work? I would like to see a completely transparent environment (with Maven console and Eclipse + this plugin), but is this possible with the Eclipse's internal compiler?
The question was regarding MNGECLIPSE-75.tar.gz project and I was asking if update source works after setting target folder not to the root of the project.
Plugin is not trying to compile anything, but it have to maintain project source folders, so Eclipse compiler will be able to do its job. Because some of the Maven plugins may introduce new source folders that are not declared in the pom.xml and that is why plugin runs generate-sources and generate-resources build lifecycle phases. Apparently we have missed generate-test-sources and generate-test-resources phases which is covered by MNGECLIPSE-79
You can read more about build life cycle at http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
I've checked with Maven folks and they are saying that process* not suppose to introduce new sources, but it may change existing stuff. So, we only need to use generate* phases.
Ok. Thank you for the explaination about the working of the plugin. I will leave the question regarding MNGECLIPSE-75.tar.gz project for Jochen to answer, but it worked when I reproduced it using that project (not the XmlBeans one).
I read up on the build life cycle before I saw your link, but thanks anyway.
Guess I am done here. I appreciate you talking to time to reply on comments as quickly as you've done.
First of all, I apologize for confusing this bugs handling by attaching my test project. I had the impression it would be related.
Yes, after changing the source folders, I can do an "Update source folders".
Ray, there is an issue with doing things this way. The trouble is that Eclipse before 3.2M5 very much don't like if somebody else is messing up with its classes.
For example, if you run Maven build and then will try to refresh Eclipse files there is a good chance that you'll see all kind of weird errors in Problems view and you will have to explicitly run project clean. And because of that it is better to keep classes compiled by Eclipse and by Maven separate. So, I am leaning towards single output folder like target/eclipse, which will also most likely improve performance of cleanup on full rebuild.
the best approach would be to add a preference on Maven preferences panel "Share output folder", so user could choose to use shared target directory between Maven and Eclipse or not.
Eugene, I see the problem. I just made a patch that adds the "Share output folder" option, as well as a default output folder if it's not shared.
I also noticed the output folder for resources were set to themselves for a reason, I've also restored that behavior when output folders are not shared.
Update sources action now sets default ouput folder to location specified in project pom.
Eugene,
Jochen's issue does not seem to be related or? Has the original problem - that I reported - been fixed?
If not, then I have to say that it feels a bit weird since I reported an issue which was then changed to something else because of Jochen's comment.
It could be. Anyways, both issues should be resolved now. Feel free to open another bug if it won't work for you in 0.0.10 relase.
Great. Thanks. I'll open a new bug if the problem persists after 0.10 is released.
We have an action "Update Source Folders" in Maven2 menu. It should include your generated sources into the classpath. If it does not work as expected, then please attach sample project with XmlBeans that would allow to reproduce this issue.
You can also vote for https://bugs.eclipse.org/bugs/show_bug.cgi?id=100508