Azure-Samples/azure-spring-boot-samples

How to maintain Spring Cloud Azure 4.x and 6.x samples

fangjian0423 opened this issue · 1 comments

At first, Branch main maintain Spring Cloud Azure 4.x version and branch feature/spring-boot-3 maintain Spring Cloud Azure 6.x version.

The samples of 4.x and 6.x are mostly same, it seems no need to maintain these 2 versions in 2 branches.

So we decide to use this #614 to split 2 versions by different pom: azure-spring-boot-samples-4.x-pom.xml and azure-spring-boot-samples-6.x-pom.xml.

After merge PR, the project struct in Intellij IDEA is very not friendly to developers.

image

We should discuss how to improve them.

Goal

Resolve maintain duplicate codes in 2 branches.

Use maven profile could putting them in one pom, like this:

<profiles>
  <profile>
    <id>spring-cloud-azure-4.x</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
      <version.guava>31.1-jre</version.guava>
      <version.spring.cloud>2021.0.5</version.spring.cloud>
      <version.spring.cloud.azure>4.5.0</version.spring.cloud.azure>
      <version.spring-cloud-appconfiguration-config>2.10.0</version.spring-cloud-appconfiguration-config>
      <version.spring-cloud-appconfiguration-starter>2.10.0</version.spring-cloud-appconfiguration-starter>
      <version.spring-cloud-feature-management>2.9.0</version.spring-cloud-feature-management>
      <version.azure-spring-boot-starter-keyvault-certificates>3.14.0</version.azure-spring-boot-starter-keyvault-certificates>
    </properties>
    <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-dependencies</artifactId>
          <version>2.7.6</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-dependencies</artifactId>
          <version>${version.spring.cloud}</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
        <dependency>
          <groupId>com.azure.spring</groupId>
          <artifactId>spring-cloud-azure-dependencies</artifactId>
          <version>${version.spring.cloud.azure}</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
        ...
      </dependencies>
    </dependencyManagement>
  </profile>
  <profile>
    <id>spring-cloud-azure-6.x</id>
    <properties>
      <java.version>17</java.version>
      <version.spring.cloud>2022.0.0-RC2</version.spring.cloud>
      <version.spring.cloud.azure>6.0.0-beta.4</version.spring.cloud.azure>
      <version.thymeleaf-extras-springsecurity6>3.1.1.RELEASE</version.thymeleaf-extras-springsecurity6>
    </properties>
    <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-dependencies</artifactId>
          <version>3.0.0-RC2</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-dependencies</artifactId>
          <version>${version.spring.cloud}</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
        <dependency>
          <groupId>com.azure.spring</groupId>
          <artifactId>spring-cloud-azure-dependencies</artifactId>
          <version>${version.spring.cloud.azure}</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
        ...
      </dependencies>
    </dependencyManagement>
  <profile>
    <id>buildpack-4x</id>
  </profile>
  <profile>
    <id>native-4x</id>
  </profile>
  </profile>
</profiles>

Then run maven command with different profile:

mvn clean install -P spring-cloud-azure-4.x,buildpack-4x

mvn clean install -P spring-cloud-azure-6.x