Hi all,
I know this is the group for the CodeHaus/MojoHaus plugin, but I'm trying to reach GWT + Maven users so…
The net.ltgt.gwt.maven:gwt-maven-plugin's import-sources and import-test-sources goals, in addition to declaring all source roots as resources, unpack dependencies with type=java-source and add them as resources as well, so that the sources of the dependencies end up being packaged within the gwt-lib.
This is something that can be accomplished using dependency:unpack or dependency:unpack-dependencies and explicitly declaring the <resource> (or using build-helper:add-resource).
I was trying to document which one of type=java-source and classifier=sources you should use, and I realized that type=java-source is only useful in a limited number of cases.
I therefore would like to remove that "feature" from the plugin. What do you think?
Below is the documentation I had written. Note that the "special treatment for reactor dependencies" actually only works because of a bug in Maven 3.0 that has been fixed in 3.1 (and we're already at 3.3); in Maven 3.1+, the dependency "needs to be packaged already at the time it's needed", just like with classifier=sources, so it's not a compelling argument (and I'll soon update the gwt-maven-archetypes to better support Maven 3.1+ with gwt:codeserver and gwt:devmode)
$h3 Sources classifier vs. `java-source` type
When adding a dependency on the sources of a shared library, Maven allows you to reference it in two ways:
using `<type>java-source</type>` or `<classifier>sources</classifier>`.
There's a big difference between those two forms:
* a `<type>java-source</type>` is not added to the classpath, it needs special processing by a plugin.
The [`gwt:import-sources`](import-sources-mojo.html) and [`gwt:import-test-sources`](import-test-sources-mojo.html) goals
will (among other things), automatically unpack those dependencies and add the unpacked files to the project resources
so they're packaged within a `gwt-lib`.
Those goals have special treatment for reactor dependencies and will automatically pick sources from a referenced project
without the need for the `java-source` artifact to have been packaged already.
You can declare the `<resource>` for the unpacked folder yourself and define includes and excludes patterns
(by default, the resource is created with an `**/*.java` include pattern).
You'll want to use a `<scope>provided</scope>` to prevent those dependencies being seen transitively.
* a `<classifier>sources</classifier>` is handled just like any other JAR dependency,
so it's put in the classpath and is transitive, and needs no special treatment.
The dependency however needs to be packaged already at the time it's needed (e.g. [`gwt:compile`](compile-mojo.html)).
**So, when to use which?**
Use `<type>java-source</type>` if you want to further filter which source files will be packaged
(for example, exclude a class for which you provide a super-source),
or to limit the number of dependencies in the classpath.