Riduidel / aadarchi

A maven archetype to generate easily projects allowing architecture description using a mix of C4, agile architecture, Asciidoc and PlantUML
https://riduidel.github.io/aadarchi/
Apache License 2.0
40 stars 12 forks source link

Reintegrate readme update into maven build #331

Closed Riduidel closed 9 months ago

Riduidel commented 1 year ago

Using a github action for that is in fact suboptimal, so remove the .github/workflows/on_release_update_readme.yml action and replace it with the correct set of maven plugins

Helielzel commented 1 year ago

Currently looking for search and replace / file modifications maven plugins. I'm checking resources such as

Helielzel commented 1 year ago

And here : https://maven.apache.org/plugins/index.html

https://ant.apache.org/manual/Tasks/replace.html

https://mvnrepository.com/artifact/com.google.code.maven-replacer-plugin/maven-replacer-plugin/1.4.1 -> too old according to the guy from the previous github repo link

Helielzel commented 1 year ago

https://floverfelt.org/find-and-replace-maven-plugin/examples/basic.html Questions :

The following is a configuration to recursively process only file contents for files ending in .yml in the target directory.

<plugin>
   <groupId>io.github.floverfelt</groupId>
   <artifactId>find-and-replace-maven-plugin</artifactId>
   <executions>
      <execution>
         <id>exec</id>
         <phase>package</phase>
         <goals>
            <goal>find-and-replace</goal>
         </goals>
         <configuration>
            <replacementType>file-contents</replacementType>
            <baseDir>target/</baseDir>
            <findRegex>_</findRegex>
            <replaceValue>-</replaceValue>
            <recursive>true</recursive>
            <fileMask>.yml</fileMask>
         </configuration>
      </execution>
   </executions>
</plugin>
Riduidel commented 1 year ago
  • Does the plugin need to modify just a line in the README or a variable containing the version to change ?

Since the readme is a markdown file, which has no interpolation mechanism, we will have to directly change the line

  • Does it need to remove the .yml or can i just do it myself

You'll have to remove the yml file by youself

  • Does it need to be in a particular place in the pom.xml file or can i just put it at the end of after the last actual plugin ?

Have you ever heard about maven profiles ? Since your coe will have to be run only during maven release process, there is a way to trigger that by putting your code in a profile, and having that profile activated on release (see poml.xml)

Riduidel commented 1 year ago

See as as an example this profile

        <profile>
            <id>update_version_in_files</id>
            <build>
                <plugins>
                <plugin>
                    <groupId>com.github.ekryd.echo-maven-plugin</groupId>
                    <artifactId>echo-maven-plugin</artifactId>
                    <version>1.3.2</version>
                    <executions>
                        <execution>
                            <id>echo-maven-plugin-1</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>echo</goal>
                            </goals>
                            <configuration>
                                <message><![CDATA[Pour Gaëtan]]></message>
                                <level>INFO</level>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                </plugins>
            </build>
        </profile>
Riduidel commented 1 year ago

Command to use to test your code is mvn package --projects :system --activate-profiles settings-aadarchi,update_version_in_files

Riduidel commented 1 year ago

Then validate the README.md now contains the new version

Helielzel commented 1 year ago

Create profile not called by default which gonna take the right version number thanks to : '=[0-9]+.[0-9]+.[0-9]+ '

Helielzel commented 1 year ago

The project version on the on_release_perform_maven_release.yml file is set to default, so i have a doubt about replacing the version number from the readme by this one. (so I think I just forgotten where i have to take it. Not in the on_release_update_readme.yml I assume, since I'me supposed to delete it) But so far I've been able to modify the readme file with the find-and-replace-maven-plugin

Helielzel commented 1 year ago

Task finished, but only one issue remains : if the command is run multiple times, the SNAPSHOT is added multiple times too at the end of the version

Riduidel commented 9 months ago

Won't fix (we prefer to use the github action for that, as it generates a PR)