migrator does not honor Maven settings.xml
See original GitHub issueDescribe the bug
When scanning an application in a corporate environment including internet proxy and internal Maven Repository mirrors definend in a Maven setttings.xml
, the scan
step fails:
migrator:> scan ./myrepo
scanning './myrepo'
Checked preconditions for 'C:\Users\michael.prankl\git\myrepo'
[ok] Found pom.xml.
[ok] 'sbm.gitSupportEnabled' is 'true', changes will be committed to branch [spring-boot-3] after each recipe.
[ok] Required Java version (17) was found.
[ok] Found required source dir 'src/main/java'.
Maven 14% ????? ? 1/7 (0:00:00 / 0:00:00) Unable to download dependency org.springframework.boot:spring-boot-starter-parent:2.7.6 from the following repositories :
- file:/C:/Users/michael.prankl/.m2/repository/
- https://repo.maven.apache.org/maven2
Details of the error have been omitted. You can use the stacktrace command to print the full stacktrace.
To Reproduce Steps to reproduce the behavior:
- Define a settings.xml containing proxy or mirror:
<settings
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>my-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>my-corporate-proxy-host</host>
<port>80</port>
</proxy>
</proxies>
</settings>
- run the scan
Expected behavior
The migrator should honor user specific maven settings defined in ~/.m2/settings.xml
, and therefore Maven should use the defined proxy for downlodas.
Screenshots
n/a
Stacktrace
org.openrewrite.maven.internal.MavenDownloadingException: Unable to download dependency org.springframework.boot:spring-boot-starter-parent:2.7.6 from the following repositories :
- file:/C:/Users/michael.prankl/.m2/repository/
- https://repo.maven.apache.org/maven2
at org.openrewrite.maven.internal.MavenPomDownloader.download(MavenPomDownloader.java:311)
at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively(ResolvedPom.java:351)
at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively(ResolvedPom.java:362)
at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentsRecursively(ResolvedPom.java:308)
at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolve(ResolvedPom.java:297)
at org.openrewrite.maven.tree.ResolvedPom.resolve(ResolvedPom.java:142)
at org.openrewrite.maven.tree.Pom.resolve(Pom.java:92)
at org.openrewrite.maven.MavenParser.parseInputs(MavenParser.java:113)
at org.springframework.sbm.build.impl.RewriteMavenParser.parseInputs(RewriteMavenParser.java:71)
at org.springframework.sbm.project.parser.MavenProjectParser.parse(MavenProjectParser.java:102)
at org.springframework.sbm.project.parser.ProjectContextInitializer.initProjectContext(ProjectContextInitializer.java:54)
at org.springframework.sbm.engine.commands.ScanCommand.execute(ScanCommand.java:57)
at org.springframework.sbm.shell.ScanShellCommand.scan(ScanShellCommand.java:70)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.shell.command.invocation.InvocableShellMethod.doInvoke(InvocableShellMethod.java:306)
at org.springframework.shell.command.invocation.InvocableShellMethod.invoke(InvocableShellMethod.java:232)
at org.springframework.shell.command.CommandExecution$DefaultCommandExecution.evaluate(CommandExecution.java:158)
at org.springframework.shell.Shell.evaluate(Shell.java:208)
at org.springframework.shell.Shell.run(Shell.java:140)
at org.springframework.shell.jline.InteractiveShellRunner.run(InteractiveShellRunner.java:73)
at org.springframework.shell.DefaultShellApplicationRunner.run(DefaultShellApplicationRunner.java:65)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:762)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:752)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
at org.springframework.sbm.SpringShellApplication.main(SpringShellApplication.java:27)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Desktop (please complete the following information):
- OS: Windows
- Version: 21H2
Issue Analytics
- State:
- Created 10 months ago
- Comments:5
Top Results From Across the Web
Using Maven settings.xml properties inside Spring context
When the migration is complete, you will access your Teams at stackoverflowteams.com, and they will no longer appear in the left sidebar on ......
Read more >Maven Publish Plugin stopped honoring the local maven ...
I just moved from gradle 1.8 to gradle 1.10. Can it be that the publish maven plugin does not honor my local maven...
Read more >Settings Reference - Maven
The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml...
Read more >Custom settings.xml is not honored by Quarkus (1.3 ... - GitHub
Custom settings.xml is not honored by Quarkus when the path is relative. Workaround is to set absolute path to settings.xml.
Read more >Fix list for IBM WebSphere Application Server V8.5
disabledAlgorithms property is not honored in a certain Java thin client ... WebSphere Common Configuration Model (WCCM), PH38310, Xml parser does not ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No worries @fabapp2 Thank you for fixing this issue and maintaining this project.
Hi @sleicht sorry for pointing you to an erroneous app. The motivation to introduce
MavenSettingsInitializer
was simpler testing (and arguably separation of concern). But to make testing simpler it needs to be replaceable, thus the constructor injection. I removed theRewriteMavenParser
constructor taking aPath
which was not a good idea in the first place and was also preventing DI and leading to the error you mentioned. It’s merged and should work now.