Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-480: Bring back POM revision property #481

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

artembilan
Copy link
Member

Fixes: #480

  • Add flatten-maven-plugin to resolve properties and remove unnecessary build info from the final POM of the artifact to install/deploy

Fixes: spring-projects#480

* Add `flatten-maven-plugin` to resolve properties
and remove unnecessary build info from the final POM of the artifact to install/deploy
@artembilan artembilan requested a review from snicoll December 18, 2024 19:48
@artembilan
Copy link
Member Author

The final result is as simple as this:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.springframework.retry</groupId>
  <artifactId>spring-retry</artifactId>
  <version>2.0.12-SNAPSHOT</version>
  <name>Spring Retry</name>
  <description>Spring Retry provides an abstraction around retrying failed operations, with an
		emphasis on declarative control of the process and policy-based behaviour that is
		easy to extend and customize. For instance, you can configure a plain POJO
		operation to retry if it fails, based on the type of exception, and with a fixed
		or exponential backoff.</description>
  <url>https://github.com/spring-projects/spring-retry</url>
  <organization>
    <name>Spring IO</name>
    <url>https://spring.io</url>
  </organization>
  <licenses>
    <license>
      <name>Apache 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>
  <developers>
    <developer>
      <id>dsyer</id>
      <name>Dave Syer</name>
      <email>[email protected]</email>
    </developer>
    <developer>
      <id>garyrussell</id>
      <name>Gary Russell</name>
      <email>[email protected]</email>
    </developer>
    <developer>
      <id>artembilan</id>
      <name>Artem Bilan</name>
      <email>[email protected]</email>
    </developer>
  </developers>
  <scm>
    <connection>scm:git:git://github.com/spring-projects/spring-retry.git</connection>
    <developerConnection>scm:git:ssh://[email protected]/spring-projects/spring-retry.git</developerConnection>
    <url>https://github.com/spring-projects/spring-retry</url>
  </scm>
  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>6.0.23</version>
      <scope>compile</scope>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-core</artifactId>
      <version>1.10.13</version>
      <scope>compile</scope>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>com.github.spotbugs</groupId>
      <artifactId>spotbugs-annotations</artifactId>
      <version>4.8.6</version>
      <scope>compile</scope>
      <optional>true</optional>
    </dependency>
  </dependencies>
  <profiles>
    <profile>
      <id>spring</id>
      <repositories>
        <repository>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <id>spring-snapshots</id>
          <name>Spring Snapshots</name>
          <url>https://repo.spring.io/snapshot</url>
        </repository>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>spring-milestones</id>
          <name>Spring Milestones</name>
          <url>https://repo.spring.io/milestone</url>
        </repository>
      </repositories>
    </profile>
  </profiles>
</project>

Pay attention to the <flattenMode>oss</flattenMode> of the plugin.

Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about reverting the change in the release pipeline as well?

It should also add .flattened-pom.xml in .gitignore.

pom.xml Show resolved Hide resolved
pom.xml Outdated
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clean goal does not need the configuration about flatten mode and the rest of it. Given it is specific to the flatten goal, it should be moved there for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean, but indeed don’t need clean here at all since I made the flatten result be in the target dir, which is cleaned by standard goal. Plus that would make no need for the gitignore as well.

@artembilan
Copy link
Member Author

Hey, Stephan!
Thank you for feedback!
I’ll revert GHA workflow, but IMHO what I did there is more Maven natural and it works with revision and without.
There is also similar commas to set version:

mvn versions:set -DnewVersion=2.0.12 -N versions:update-child-modules -DgenerateBackupPoms=false

* Remove `flatten.clean` from the Maven Flatter Plugin, since `.flattened-pom.xml` generated file is landed in the `/target` dir
* Add `pomElements/profiles` for removal in the result `.flattened-pom.xml`
@artembilan artembilan requested a review from snicoll December 23, 2024 18:17
Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.flattened-pom.xml is still missing in .gitignore.

<artifactId>flatten-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.flattened-pom.xml is still missing in .gitignore.

We don't need that because the file is stored into a target directory which is already under ignore.
I don't see any argument why this file has to be in the root project dir when we are interested in it only at runtime on install or deploy, so that is indeed a volatile entity for project build lifecycle and that is totally enough to have it in the target alongside with the rest of artifacts to deliver.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do that, you don't need clean then. Again, if you decide to do things differently, please do that consistently.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. That’s what I did in the last commit. Please, double check the latest change set in the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider reverting change to revision attribute in pom
2 participants