repaint-io / maven-tiles

Injecting maven configurations by composition rather than inheritance
154 stars 32 forks source link

Support including parameterized tile multiple times #74

Open udalrich opened 6 years ago

udalrich commented 6 years ago

I would like to define a tile that starts a docker container for use during integration tests. I can do that easily enough by creating a tile that uses the appropriate plugin.

In some cases, I need to start multiple docker containers (e.g., message broker and a db). In that case, it appears that I need to copy the tile for the first container and make the slight changes to start the second container. It would eliminate duplication if I could do something like

start-docker/tile.xml

<project><build><plugins><plugin>
       group, artifact and version
       <executions>
          <execution>
            <goal>start-container</goal>
            <configuration>
                 <image>@imageName@</image
            </configuration
         </execution>
         <!-- Other executions -->
       <executions>
   </plugin></plugins></build></project>

start-db/tile.xml

<project>
      <tiles>
          <tile>
             <source>me:start-docker:1.0<source>
             <properties>
                  <imageName>db</imageName>
             </properties>
          </tile>
      </tiles>
 </project>

start-msg-broker/tile.xml

<project>
      <tiles>
          <tile>
             <source>me:start-docker:1.0<source>
             <properties>
                  <imageName>msg-broker</imageName>
             </properties>
          </tile>
      </tiles>
 </project>

component/pom.xml

...
         <plugin>
            <groupId>io.repaint.maven</groupId>
            <artifactId>tiles-maven-plugin</artifactId>
            <version>2.10</version>
            <configuration>
                <filtering>true</filtering>
                <tiles>
                    <tile>me:start-db:1.0</tile>
                    <tile>me:start-msg-broker:1.0</tile>
                </tiles>
            </configuration>
        </plugin>

Alternatively, if there was a way to override the location of tile.xml, then I could import the tile in start-db/pom.xml and do the filtering before the tile plugin ran. I suppose that I could create the tile.xml in that manner, but that is likely to be confusing, as I would have a build product outside of target.

rvowles commented 6 years ago

All the tiles are doing are side-loading and creating an inheritance structure - so your properties will be overwritten and you would still only have one docker image.

Have you tried just defining the same plugin but with a different execution (with its own id) and have the plugin merge them? Thats what it should do. You should end up with one plugin in your effective pom with 2 executions.