在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):repaint-io/maven-tiles开源软件地址(OpenSource Url):https://github.com/repaint-io/maven-tiles开源编程语言(OpenSource Language):Groovy 99.8%开源软件介绍(OpenSource Introduction):Tiles Maven Plugin - Version 2.29OverviewThe tiles-maven-plugin is a Maven Plugin that tries to bringing the composition that is available to dependencies to the parent structure as well. How do I make a Maven Tile?Tiles are plain Maven pom artifacts which contain parts of a Maven POM; every tile can contain
This could, for example, allow you to have build aspects consistent across your organization and open sourced, and the distribution of internal vs external artifacts kept in a single tile. In the current single parent hierarchy, this is all duplicated. Where can’t I use a Maven Tile?The following are Repaint project definitions:
With those defined:
Composing a Maven TileA Maven Tile is made up of a pom.xml and a tile.xml. The pom.xml contains the normal release information. When using tiles, this would be the name/groupId/artifactId/version/description/packaging(tile) and generally only a declaration of the Maven Tiles plugin. Only if you are using a tile (and generally you use at least one - the release tile) will you specify a configuration. pom.xml
<project>
<groupId>io.repaint.maven</groupId>
<artifactId>license-tile</artifactId>
<version>1.1-SNAPSHOT</version>
<packaging>tile</packaging>
<description>Contains consistent license information.</description>
<modelVersion>4.0.0</modelVersion>
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.29</version>
<extensions>true</extensions>
<configuration>
<filtering>false</filtering>
<tiles>
<tile>io.repaint.tiles:github-release-tile:[1.1, 2)</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project> With the packaging tile, the plugin will look for the attached tile.xml, do some basic validation on it and attach it as an artifact. When the tile.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
</project> A tile can define the tiles plugin if it wishes to cascade tile inclusion, or it can use the extended tile.xml syntax: tile.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<tiles>
<tile>io.repaint.tiles:ratpack-tile:[1,2)</tile>
</tiles>
</project> Although this will appear to not validate when editing in an IDE, the tile plugin will strip off the tiles section when processing and use it directly. Execution IdsExecution ids within tiles are prepended with the gav parameters of the tile that included the execution, for easier
debugging / tracing. If this is not desired, adding a configuration attribute tile.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<build>
<plugins>
<plugin>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>1</id>
</execution>
<execution>
<id>2</id>
<configuration tiles-keep-id="true" />
</execution>
<execution>
<id>3</id>
<configuration>
<tiles-keep-id>true</tiles-keep-id>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>test</id>
<build>
<plugins>
<plugin>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>4</id>
</execution>
<execution>
<id>5</id>
<configuration tiles-keep-id="true" />
</execution>
<execution>
<id>6</id>
<configuration>
<tiles-keep-id>true</tiles-keep-id>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> In the above tile, executions with ids 1 and 4 will have their ids changed to
Build SmellsWhen migrating from a parent structure, it is worthwhile to take the opportunity to reduce your build smells. You can do this gradually or in one go, depending on how your builds are done. By default, the plugin will strip all bad smells. The following is an explanation of what is stripped and why those smells are bad. Richard and Mark will be putting together a short book with tutorials for a better approach to building using Maven, but this is the short explanation. Note, these are only cleaned from the tile.xml, not from your pom.xml.
Almost made a build smell: - pluginmanagement - plugin management is used in parents to define all of the necessary options for a plugin but not have that plugin actually run during the release of the parent artifact, and also give the child the option of running it. The reason this is bad is that it is mostly not necessary. You should split your plugins up into tiles so that they be pulled into a build as a standalone set of functionality that will always run and be properly configured. Since they will reside in the tile.xml file, they will not be run when the tile is released. However, some plugins are never run automatically - release and enforcer are two examples. These make sense to stay in pluginManagement. If you need to use them, add them to your configuration section: pom.xml
<build>
<modelVersion>4.0.0</modelVersion>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.15</version>
<configuration>
<buildSmells>dependencymanagement, dependencies, repositories, pluginrepositories</buildSmells>
<tiles>
<tile>groupid:antrun1-tile:1.1-SNAPSHOT</tile>
<tile>groupid:antrun2-tile:1.1-SNAPSHOT</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build> Composing Build functionalityAs a use case, an example of how it will be used for my projects. Richard will have:
This allows me to open source all my tiles except for the nexus tile, and then decide in the final artifact where I will release it. Using Snapshots of Tiles
If you don’t wish to include
Parent structureTiles will always be applied as parents of the project that is built. Any orignal parent of that project will be added
as the parent of the last applied tile. So if you apply Tiles However, there are situations where you want to define your tiles in a parent, e.g. when you have a lot of artifacts
that are built in the same way. In this case you would want a structure like this: pom.xml
<parent>
<groupId>group</groupId>
<artifactId>P</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>X</artifactId>
...
<build>
<plugins>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.29</version>
<configuration>
<applyBefore>group:P</applyBefore>
<tiles>
<tile>group:T1:1.0.0</tile>
<tile>group:T2:1.0.0</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build> Tile OrderingIn v2.19 and earlier, all tiles declared inside tiles are loaded after all tiles declared in the project. This meant that all tiles declared inside tiles became ancestors to all tiles declared in the project. In v2.20+, tile ordering has changed. All tiles are now loaded in order of when they are declared, recursively tracing from tiles declared in a project down to the tiles declared within tiles. Suppose your project declares tiles In some cases, your project and tile hierarchy will include duplicate declaration of one tile. In these cases, the
tile is only included once. The latest declaration is used, resulting it showing up in the Maven project
ancestry as the one closest to the parent MojosThere are two mojos in the plugin, attach-tile and validate. attach-tile is only used by the deploy/install process and attaches the tile.xml. validate is for your use to ensure your tile is valid before releasing it - this ensures it can be read and any errors or warnings about content will appear. Additional NotesSome interesting notes:
Final NotesTiles-Maven works best when you and your team own the tiles. I don’t recommend relying on open source tiles, always create your own versions and always lock down versions of third party tiles, just like you would third party dependencies. Read More
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论