Maven and profiles: using the same plugin in two different profiles and using both at the same time

We use the frontend-maven-plugin to use grunt and gazebo in our builds. With the Frontend Maven plugin, I can install NPM locally, use Bower to load Java libraries, and run Grunt to optimize and obfuscate my code.

Like this with some simplification:

<plugin>
  <groupId>com.github.eirslett</groupId>
  <artifactId>frontend-maven-plugin</artifactId>
  <version>0.0.24</version>
  <executions>
    <execution>
      <id>install node and npm</id>
      <goals> <goal>install-node-and-npm</goal> </goals>
      ...
    </execution>
    <execution>
      <id>npm-install</id>
      <goals> <goal>npm</goal> </goals>
      ...
    </execution>
    <execution>
      <id>bower-install</id>
      <goals> <goal>bower</goal> </goals>
      ...
    </execution>
    <execution>
      <id>grunt-build</id>
      <goals> <goal>grunt</goal> </goals>
      ...
    </execution>
  </executions>
</plugin>

Note that the latest execution is grunt-build, in which JavaScript files are merged together, optimized (returns, comments, and other things removed) and obfuscation.

. , , JavaScript , . . grunt-build .

. development, . pom.xml, . .

, . 50 pom.xml.

, , - , , . . , Java, . , .

, frontend-maven-plugin . development . , , frontend-maven-plugin, , frontend-maven-plugin, grunt.

pom.xm, Maven ?

+4
2

, grunt skip, true .

, development, skipGrunt true , false.

grunt

<configuration>
    <skip>${skipGrunt}</skip>
    <!-- rest of configuration -->
</configuration>

: , skip, true.

+3

Maven:

, , , , , .

, Maven. " ", , .

, [...]. , , , - , .

. -, .

, . Maven POM :

product ... parent POM
  +- pom.xml ... contains build steps apart from Grunt and all other declarations 
  +- dev
  |    +- pom.xml ... almost empty since everything inherited from parent
  |    +- ... sources, resources, etc. ...
  +- release
       +- pom.xml ... contains Grunt build step only, everything else inherited from parent
                      redirecting <build>/<[[test]source|resource>/]|
                          [[test]output|testresource>/]directory> to ../dev/...

. BaseBuild, Resources POM .

. Maven pom :

- .

-, .

, dev, development. .:)

+3

Source: https://habr.com/ru/post/1612825/


All Articles