Skip to content

Commit d49d4cf

Browse files
committed
Make a guess at a reasonable package prefix
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.
1 parent 633f99c commit d49d4cf

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

pom.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
<main-class />
127127

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

131131
<!-- Premain-Class attribute of the JAR artifact. -->
132132
<premain-class />
@@ -537,6 +537,24 @@
537537
<failIfNoMatch>false</failIfNoMatch>
538538
</configuration>
539539
</execution>
540+
541+
<!--
542+
Make a guess at a reasonable & legal package prefix. This value
543+
is used for package-name and automatic-module-name by default.
544+
-->
545+
<execution>
546+
<id>guess-package</id>
547+
<goals>
548+
<goal>regex-property</goal>
549+
</goals>
550+
<configuration>
551+
<name>package-guess</name>
552+
<value>${project.groupId}.${project.artifactId}</value>
553+
<regex>[^a-z0-9_.]+</regex>
554+
<replacement>_</replacement>
555+
<failIfNoMatch>false</failIfNoMatch>
556+
</configuration>
557+
</execution>
540558
</executions>
541559
</plugin>
542560

0 commit comments

Comments
 (0)