This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Maven integration does not detect target/generated-resources/[some-maven-plugin] resources | ||
---|---|---|---|
Product: | projects | Reporter: | lu4242 |
Component: | Maven | Assignee: | Tomas Stupka <tstupka> |
Status: | REOPENED --- | ||
Severity: | normal | CC: | dkonecny, juhrik, markiewb |
Priority: | P4 | ||
Version: | 6.x | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | 194090 | ||
Bug Blocks: | 191864 | ||
Attachments: | Project for create custom JSF Components with a generation tool (myfaces builder plugin) |
Description
lu4242
2011-05-16 18:33:33 UTC
If you have a sample project to demonstrate the problem, that would be great. Created attachment 108471 [details] Project for create custom JSF Components with a generation tool (myfaces builder plugin) I have attached a maven project for create custom JSF components using MyFaces builder plugin. It generates a .tld and a .taglib.xml file, but when you open the webapp, the files are not readed, because target/generated-resources/myfaces-builder-plugin is not marked as a valid path. Obviously you can do this: <resource> <directory>target/generated-resources/myfaces-builder-plugin</directory> </resource> But the big question is add that is required or not. mvn eclipse:eclipse is smart enough to add the path (take the same project, run mvn eclipse:eclipse and load it with eclipse helios with import >> existing eclipse project into workspace), why netbeans do not? The code that adds the resource path on myfaces-builder-plugin is here: http://svn.apache.org/repos/asf/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/BuildMetaDataMojo.java the lines: // Tell Maven to add this directory to its "resources" path. // The maven-resources-plugin will then copy all the files // from this directory to its own target directory, which is // where the final jar artifact is built from. addResourceRoot(project, targetDirectory.getCanonicalPath()); and protected void addResourceRoot(MavenProject project, String resourceRoot) { List resources = project.getBuild().getResources(); Resource resource = new Resource(); resource.setDirectory(resourceRoot); resources.add(resource); } Thanks for investigation. There is already code which adds any target/generated-sources/* dirs to the IDE's notion of the source path. This could just be extended to add target/generated-resources/* to the source path (and define source roots of resource type, just like src/main/resources). I can also check whether it is feasible to inspect $project.build.resources (etc.) from the embedder rather than hardcoding these file paths, which would perhaps be more general and reliable. (In reply to comment #3) > I can > also check whether it is feasible to inspect $project.build.resources (etc.) > from the embedder rather than hardcoding these file paths Seems impossible; these modifications are made during actual mojo execution. Whereas m2eclipse runs Maven in-VM for actual builds, NB forks Maven to build; it does call Maven to load projects, but this does not involve calling into plugin code; and AFAIK there is no way to ask plugins what (re)source roots they _would_ add without actually generating files and so on. It is conceivable that bug #194090 could be used to detect (re)source roots precisely after the project is built, but there would still need to be some heuristic in place for a freshly opened but unbuilt project; and changes to the POM would only be "noticed" by the IDE upon rebuilding. Also need to handle build-helper:add-resource and build-helper:add-test-resource. *** Bug 154486 has been marked as a duplicate of this bug. *** is a feasible workaround to just change the location to target/generated-sources/FOO? we put sources and resources on the same classpath, only care about resource roots when creating new resources by the IDE. I tried to set generated-sources instead generated-resources, just updating some params in myfaces-builder-plugin and it does not work with netbeans 7.2. There are two problems: - The generated sources (.java) are added to the jar file too, because "generated-sources" folder is added as resources folder. - Generated resources are not copied to target/classes folder. By the previous reasons, it has more sense to use generated-resources/[my maven plugin] as this issue suggest. Note that according to maven, both sources and resources are in different folders because both requires different treatement. Sources are compiled and the result is put on target/classes. Resources are filtered/copied/transformed and the final result is put on target/classes. Mixing both of them is not an option. (In reply to comment #8) > I tried to set generated-sources instead generated-resources, just updating > some params in myfaces-builder-plugin and it does not work with netbeans 7.2. > There are two problems: > > - The generated sources (.java) are added to the jar file too, because > "generated-sources" folder is added as resources folder. I didn't suggest target/generated-sources to become the resources root, but target/generated-sources/FOO where foo is the unique identifier for the plugin's output. > > - Generated resources are not copied to target/classes folder. I'm not getting how that can be. Are you talking pure maven or some interaction with netbeans Compile-on-Save feature? In pure maven, if you change just the parameter for location, then the plugin will just generate into a different location but everything else stays the same. The desired effect was to get the resources show up on classpath and will be noticed by the web related modules. IMHO at least, I don't have a working example project. looking at http://myfaces.apache.org/build-tools/plugins/myfaces-builder-plugin/plugin-info.html I'm not even clear which goal are you using in your project, all parameters I found discuss adding a source root, not resource root. > > By the previous reasons, it has more sense to use generated-resources/[my maven > plugin] as this issue suggest. Note that according to maven, both sources and > resources are in different folders because both requires different treatement. > Sources are compiled and the result is put on target/classes. Resources are > filtered/copied/transformed and the final result is put on target/classes. > Mixing both of them is not an option. That's not what my suggested workaround was meant to accomplish. changing the root to a location the IDE understands has no influence whatsoever on how maven interprets the values. Maven should be humming along the same as before, unless you made some configuration error. Or I misunderstood your problem. A sample project would speak 1000 of words here. Ok, now I get it. I was thinking on a solution without change the convention for /generated-sources/[maven-plugin-artifactId]. I tried to redirect the generated resources to /generated-sources/[maven-plugin-artifactId]-resources and it works (before I was mixing both resources and sources on the same dir). It works, the IDE recognize both paths, and is able to take the generated .taglib.xml or .tld and use that information to edit .xhtml (jsf) pages. I can update my config, rebuild, and the changes are reflected in the edition/code completion. Since there is no naming convention in this part defined by maven, it is a valid solution (but I like more the one proposed from start). Please close this issue as invalid or won't fix or whatever. Anyway, the question is still open, it seems something to be defined by maven, but anyway, I can fix the problem just setting some params in myfaces-builder-plugin configuration. Thanks for your help. i'm keeping the issue open because in order to have all features working correctly the IDE should know the difference between source and resource root. But technically the impact is still unknown and most likely small. ->p4 This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue. Thanks for your cooperation, NetBeans IDE 8.2 Release Boss (In reply to Milos Kleint from comment #11) > i'm keeping the issue open because in order to have all features working > correctly the IDE should know the difference between source and resource > root. But technically the impact is still unknown and most likely small. ->p4 Still valid in 8.2 dev Product Version: NetBeans IDE Dev (Build 201607100002) |