dotCMS / core

Headless/Hybrid Content Management System for Enterprises
http://dotcms.com
Other
857 stars 467 forks source link

Jreleaser failing due to validate step not loading properties #28951

Closed spbolton closed 3 months ago

spbolton commented 3 months ago

Jreleaser is failing with the following error.

Warning:  Variables source /home/runner/.jreleaser/config.properties does not exist
[INFO] Validating configuration
[INFO] Strict mode set to false
Error:  == JReleaser ==
Error:  java.lang.IllegalArgumentException: Cannot parse version '${ext'

The issue was triggered by a change to make the compatibility java versions default come from the environments/environment.properties file with <maven.compiler.release>${ext.java.compat.version}</maven.compiler.release> The command we were using to run jreleaser is

tools/dotcms-cli/mvnw -B -Prelease jreleaser:full-release -DartifactsDir=artifacts -Djreleaser.git.root.search=true -pl :dotcms-cli-parent -Dmaven.plugin.validation=VERBOSE

This command only runs the jreleaser plugin itself without and pre steps which include loading the proprties files which occurs in the initial validate phase. They way to change this is to change the command to run the validate phase and then the jreleaser execution to the phase. e.g.

we add the execution to the profile, and then change the command to the following to run all plugins in the initial validation step including jreleaser that is now attached to this phase.

tools/dotcms-cli/mvnw -B validate -DartifactsDir=artifacts -Djreleaser.git.root.search=true -pl :dotcms-cli-parent -Dmaven.plugin.validation=VERBOSE

To note: An alternative is to not tie the plugin to the phase and just run validate phase followed by the plugin itself e.g.

tools/dotcms-cli/mvnw -B -Prelease validate  jreleaser:full-release -DartifactsDir=artifacts -Djreleaser.git.root.search=true -pl :dotcms-cli-parent -Dmaven.plugin.validation=VERBOSE

any phase after validate would work bug does more work. When running plugins out of their normal build phase it is important to make sure that it has everything it needs already.

I need to come back in and look more on the structure here as it is a little unusual and breaks maven conventions to attach this plugin and config into the parent pom here, it probably should be in the main cli module itself

This fix will just solve the immediate problem allowing JReleaser to get the correct java version and run as it did previously.

<profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jreleaser</groupId>
            <artifactId>jreleaser-maven-plugin</artifactId>
            <version>${jreleaser-plugin.version}</version>
            <inherited>false</inherited>
            <configuration>
              <gitRootSearch>true</gitRootSearch>
              <configFile>${project.basedir}/jreleaser.yml</configFile>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>full-release</goal>
                </goals>
                <phase>validate</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

Testing

The issue can be triggered locally by running the same command e.g.

./mvnw -B -Prelease jreleaser:full-release -DartifactsDir=artifacts -Djreleaser.git.root.search=true -pl :dotcms-cli-parent -Dmaven.plugin.validation=VERBOSE

The command will still otherwise error about the password being blank, but it will still throw the error "Cannot parse version '${ext'" which will no longer occur with the updated command after the plugin configuration has been changed. Note The versions of jreleaser plugin and enforcer plugins should also be upgraded as they throw warnings indicating they are not up to date with the version of maven.

jgambarios commented 3 months ago

Passed internal as I see not error similar or equals to "Cannot parse version '${ext'", as expected and as mentioned in the ticket description, I only see the errors related to the passwords and tokens being blank. Also, the warnings related to the plugins version are gone.