rewrite icon indicating copy to clipboard operation
rewrite copied to clipboard

MavenSettings.java in package "org.openrewrite.maven" not picking configuration in server tag in settings.xml

Open skazaruddin opened this issue 1 year ago • 2 comments

I am using

  • OpenRewrite v8.32.0
  • Maven - 3.9.8
  • rewrite-maven-plugin - 5.37.1

How are you running OpenRewrite?

I am using maven plugin , and its a single module project

Can you share your configuration so that we can rule out any configuration issues?

<plugin>
	<groupId>org.openrewrite.maven</groupId>
	<artifactId>rewrite-maven-plugin</artifactId>
	<version>5.37.1</version>
	<configuration>
		<activeRecipes>
		<recipe>org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_2</recipe>
		</activeRecipes>
	</configuration>
	<dependencies>
		<dependency>
			<groupId>org.openrewrite.recipe</groupId>
			<artifactId>rewrite-spring</artifactId>
			<version>5.15.0</version>
		</dependency>
	</dependencies>
</plugin>

What is the smallest, simplest way to reproduce the problem?

Configure settings.xml

  <servers>
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
      <configuration>
          <timeout>10000</timeout>
      </configuration>    
    </server>
    </servers>

Use the following pom.xml and use command "mvn -X rewrite:dryRun", put debug on Line 94 MavenRepositoryMirror.java, the configuration property is blank / null in MavenSettings object.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.0.13</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.bezkoder</groupId>
	<artifactId>spring-boot-3-rest-api-example</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>spring-boot-3-rest-api-example</name>
	<description>Spring Boot 3 Rest API example</description>
	<properties>
		<java.version>17</java.version>
		<jackson.version>2.15.3</jackson.version>
		<sonar.sourceEncoding>Cp1252</sonar.sourceEncoding>
		<resilience4jVersion>2.0.2</resilience4jVersion>
		<jacoco.version>0.8.8</jacoco.version>
	</properties>

	<dependencyManagement>
		<dependencies>
		<!-- https://mvnrepository.com/artifact/io.awspring.cloud/spring-cloud-aws-dependencies -->
			<dependency>
				<groupId>software.amazon.awssdk</groupId>
				<artifactId>bom</artifactId>
				<version>2.20.92</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<!-- https://mvnrepository.com/artifact/io.awspring.cloud/spring-cloud-aws-dependencies -->
			<dependency>
				<groupId>io.awspring.cloud</groupId>
				<artifactId>spring-cloud-aws-dependencies</artifactId>
				<version>3.0.2</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>

			<dependency>
				<groupId>io.netty</groupId>
				<artifactId>netty-handler</artifactId>
				<version>4.1.108.Final</version>
			</dependency>

			<dependency>
				<groupId>org.yaml</groupId>
				<artifactId>snakeyaml</artifactId>
				<version>2.0</version>
			</dependency>

			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-expression</artifactId>
				<version>6.0.8</version>
			</dependency>

			<dependency>
				<groupId>org.mozilla</groupId>
				<artifactId>rhino</artifactId>
				<version>1.7.12</version>
			</dependency>

		</dependencies>
	</dependencyManagement>

	<dependencies>

		<dependency>
			<groupId>software.amazon.awssdk</groupId>
			<artifactId>secretsmanager</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-webflux</artifactId>
			<exclusions>
				<exclusion>
					<groupId>io.netty</groupId>
					<artifactId>netty-codec-http2</artifactId>
				</exclusion>
				<exclusion>
					<groupId>io.netty</groupId>
					<artifactId>netty-handler</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.springframework</groupId>
					<artifactId>spring-web</artifactId>
				</exclusion>
				<exclusion>
					<groupId>ch.qos.logback</groupId>
					<artifactId>logback-classic</artifactId>
				</exclusion>
				<exclusion>
					<groupId>io.netty</groupId>
					<artifactId>netty-codec-http</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

 </dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.openrewrite.maven</groupId>
				<artifactId>rewrite-maven-plugin</artifactId>
				<version>5.37.1</version>
				<configuration>
					<activeRecipes>
					<recipe>org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_2</recipe>
					</activeRecipes>
				</configuration>
				<dependencies>
						<dependency>
							<groupId>org.openrewrite.recipe</groupId>
							<artifactId>rewrite-spring</artifactId>
							<version>5.15.0</version>
						</dependency>
						</dependencies>
</plugin>
		</plugins>
	</build>

</project>

skazaruddin avatar Aug 02 '24 15:08 skazaruddin

Hi @skazaruddin ; thanks for the detail in your report! I'm seeing your server config <id>deploymentRepo</id>, but no corresponding <repository> referencing that particular server, leading me to doubt if that should even be picked up. Was that part left out of your report here, or is it missing in your configuration?

timtebeek avatar Aug 09 '24 21:08 timtebeek

Hi @timtebeek , No it was not left out, it was there in my settings.xml.

skazaruddin avatar Aug 14 '24 13:08 skazaruddin

hi @skazaruddin ! Not quite sure what's going on for you; we explicitly have tests that validate the timeout parsing: https://github.com/openrewrite/rewrite/blob/c97c7f214634c78b257e6a7eb6705727f3d46900/rewrite-maven/src/test/java/org/openrewrite/maven/MavenSettingsTest.java#L344-L371

Here's a list of the fields we map for Servers in Maven settings.xml: https://github.com/openrewrite/rewrite/blob/a98d83d698dda9971c93a0767b7f85d5866f306d/rewrite-maven/src/main/java/org/openrewrite/maven/MavenSettings.java#L395-L421

As such I don't think we have enough information to replicate your issue; Let us know if you manage to replicate this with a unit test or reproducer project.

timtebeek avatar Sep 21 '24 21:09 timtebeek