Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pom-configurable module file names #7

Closed
OliverO2 opened this issue Jun 10, 2013 · 4 comments
Closed

Allow pom-configurable module file names #7

OliverO2 opened this issue Jun 10, 2013 · 4 comments

Comments

@OliverO2
Copy link

It would be practical to have module file names configurable in the pom.xml to support this use case:

  • A pom defines a "dev" profile used for development builds.
  • To save compilation time, a "dev" build should limit GWT compilation to just one target (say, chrome/safari).
  • This can be achieved by having a separate module file "${module}_dev.gwt.xml" which inherits from the original "${module}.gwt.xml" and adds a line <set-property name="user.agent" value="safari"/>.
  • For a complete example, see gwt-maven-archetypes/guice-rf-activities/client

The configuration might look like <module>${moduleName}</module> as was the case in the codehaus gwt-maven-plugin.

@tbroyer
Copy link
Owner

tbroyer commented Jun 10, 2013

Actually, I think it's already possible:

<plugin>
  <groupId>net.ltgt.gwt.maven</groupId>
  <artifactId>gwt-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>default-compile</id>
      <configuration>
        <moduleName>it.test.E2E_dev</moduleName>
      </configuration>
    </execution>
  </executions>
</plugin>

(in a profile)

See http://maven.apache.org/guides/mini/guide-default-execution-ids.html

With a file src/main/resources/it/test/E2E_dev.gwt.xml (or something similar, e.g. a src/main/modules configured as a <resource> with a <targetPath>it/test</targetPath>) like:

<module rename-to='e2e'>
  <inherits name='it.test.E2E' />

  <set-property name='user.agent' value='safari' />
</module>

(you could also use filtering instead of hard-coding the rename-to and name values)

I'll reopen the issue if that doesn't work.

Of course, you could also just have a module in your tree with a <set-property name='user.agent' value='${gwt.user.agent}' />, inherited in your src/main/module.gwt.xml, and use filtering (with your gwt.user.agent property defaulting to, e.g., ie8,ie9,gecko1_8,safari)

…or simply not use generate-module (set <skipModule>true</skipModule> in the plugin's configuration)
…or even use filtering directly on the moduleTemplate (it defaults to src/main/module.gwt.xml but is configurable)

I don't really want to encourage this as it goes against The Maven Way™ of not varying the produced artifact. It should be possible, because alternatives are impractical at best (ideally, you should have a distinct Maven module specific to your user.agent=safari compilation), but it shouldn't be too easy or built-in.

@tbroyer tbroyer closed this as completed Jun 10, 2013
@OliverO2
Copy link
Author

You are right, your default-compile configuration works as you expected.

What actually puzzles me is this:

  • If I set moduleName to the module's real name like "it.test.E2E", the plugin seems to infer that the GWT configuration must be in a file named "module.gwt.xml" (literally). If "module.gwt.xml" doesn't exist, the plugin doesn't complain, but if a module configuration is present in a file named "it.test.E2E.gwt.xml", it is ignored.
  • In contrast, if moduleName is set to something different like "it.test.E2E_draft", that name is used as is, just appended with ".gwt.xml".

Otherwise I agree that having two different profile-dependent artifacts ending up in the same target directory is not the best solution as it requires "mvn clean" when switching configurations.

@tbroyer
Copy link
Owner

tbroyer commented Jun 11, 2013

The problem is lack of documentation.

moduleName is used in many goals:

  • generate-module-metadata for gwt-lib packaging,

  • compile for gwt-app packaging,

  • and

    • add-super-sources (when relocateSuperSources is set to true),
    • add-test-super-sources (when relocateTestSuperSources is set to true) and
    • generate-module

    for gwt-lib and gwt-app packagings.

generate-module uses moduleName as its output, overwriting any such file that could be present in the project resources.
All other goals use moduleName as their input, looking for a file with the appropriate name or assuming one is present.

@OliverO2
Copy link
Author

Ah, I see, thanks for clarifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants