Skip to content

Commit

Permalink
Make a guess at a reasonable package prefix
Browse files Browse the repository at this point in the history
Our goal here is to choose a likely-to-be-unique, descriptive and legal
name, Not to glean what the actual package prefix is for the project.

This is important because the package-name is also used as the
automatic-module-name value by default.

Unfortunately, it seems regex-property cannot operate on properties
defined in the <properties> section -- only those basic properties of
the project such as project.groupId and project.artifactId.
  • Loading branch information
ctrueden committed Jun 28, 2019
1 parent 633f99c commit d49d4cf
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<main-class />

<!-- Package attribute of the JAR artifact. -->
<package-name />
<package-name>${package-guess}</package-name>

<!-- Premain-Class attribute of the JAR artifact. -->
<premain-class />
Expand Down Expand Up @@ -537,6 +537,24 @@
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>

<!--
Make a guess at a reasonable & legal package prefix. This value
is used for package-name and automatic-module-name by default.
-->
<execution>
<id>guess-package</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>package-guess</name>
<value>${project.groupId}.${project.artifactId}</value>
<regex>[^a-z0-9_.]+</regex>
<replacement>_</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>

Expand Down

0 comments on commit d49d4cf

Please sign in to comment.