Open natalia-pokrovskaya opened 1 month ago
Hi @natalia-pokrovskaya ; thanks for the detailed report. Since it looks to be an internal parent that can not be upgraded I'm wondering if your repositories are configured correctly. Does it work when you try to change the parent pom from one that's available in Maven Central?
I created a very simple project (don't blame me, blame the chatbot for the bad code :p):
structure:
my-parent-project/
├── pom.xml
├── my-module/
│ └── pom.xml
```xml
```xml
Step 1: see that it compiles (✅) Step 2: add rewrite to it:
(See bottom for build plugin -- literally taken from @natalia-pokrovskaya 's example above)
```xml
Step 2b: Add my-module/rules.yml [strange location -- not the root, but the last project executed!!!!]:
```yaml type: specs.openrewrite.org/v1beta/recipe name: my.test.UpgradeParent displayName: Change Maven dependency example recipeList: - org.openrewrite.maven.ChangeParentPom: oldGroupId: org.apache.maven oldArtifactId: maven-parent newVersion: 34 ```
Step 3: run it (mvn rewrite:run -Drat.skip=true
)
Step 4: works! ‼
Result:
[INFO] --- rewrite:5.42.2:run (default-cli) @ my-module ---
[INFO] Using active recipe(s) [my.test.UpgradeParent]
[INFO] Using active styles(s) []
[INFO] Validating active recipes...
[INFO] Project [My Parent Project] Resolving Poms...
[INFO] Project [My Parent Project] Parsing source files
[INFO] Project [My Module] Parsing source files
[INFO] Running recipe(s)...
[WARNING] Changes have been made to pom.xml by:
[WARNING] org.openrewrite.maven.ChangeParentPom: {oldGroupId=org.apache.maven, oldArtifactId=maven-parent, newVersion=34}
[WARNING] Please review and commit the results.
But that would mean that the openrewrite plugin is not very useful for any project which is not on the central maven repository? Even though we have a Nexus repository where all the calls are redirected to, openrewrite still tries somehow to go to central as I understand it?
I verified that it doesn't work against an internal parent pom.
hi @svaningelgem ; thanks for reporducing. I imagine you're a colleague of @natalia-pokrovskaya and as such are using much of the same settings? OpenRewrite definitely does work for internal projects as well, but perhaps there's an issue with the specific configuration that you're using. Whenever possible we try to use <repositories>
and ~/.m2/settings.xml
to discover which internal repositories to reach out to, and what credentials to use for those. Sometimes we find those might need to be tweaked or made a little more explicit when there's internal alternative authentication schemes for instance. Are you using any Artifactory that allows you to download & provide a custom settings.xml
for instance?
You've guessed correct @timtebeek 👍 .
I have an ~/.m2/settings.xml
in which I have 1 repository set, with mirrorOf
set to *
.
Authentication scheme is via username/password, also defined in this settings file.
So, nothing out of the ordinary there (I think)...
hi @timtebeek, thank you very much for the reply! yes, we are using our internal next to proxy everything.
in my settings.xml I have:
<mirrors>
<mirror>
<id>Maven_Public</id>
<mirrorOf>*</mirrorOf>
<url>****https://nexus_URL***/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>global</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>Maven_Public</id>
<name>Nexus Public Repository</name>
<url>https://***nexus_URL***</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
but when checking for logs, I have no impression openrewrite check our custom repositories.... should we add something on the project level? How I can debug it deeply?
Thank you in advance for your help!
best regards, Natalia
In my settings file I simply have this:
<settings>
<servers>
<server>
<id>Maven_Public</id>
<username>%my username%</username>
<password>%pass%</password>
</server>
</servers>
<mirrors>
<mirror>
<id>Maven_Public</id>
<mirrorOf>*</mirrorOf>
<url>%our nexus url%</url>
</mirror>
</mirrors>
</settings>
So, a lot less than @natalia-pokrovskaya . But indeed, it looks to be bypassing our local nexus server in favor of an external one?
I have same issue,when ChangeParentPom with local mirror server .
I'm also affected by this issue.
Please, if you plan to fix it, consider creating a new parameter for the maven plugin because every project can have its own settings.xml.
I found very interesting your tool. Please, continue with this wonderful work!
Thanks.
Hello,
I have an issue running custom recipie for
org.openrewrite.maven.ChangeParentPom
Here is my configuration: A maven, multi-module project. I want to update the version of the parent of the root's pom.xml file.
Here is my configuration in rules.yml file:
In my pom.xml I have:
But when I run it with rewrite:run or rewrite:dryRun, it doesn't match my parent pom GAV and don't update it...
I tried to specify newArtifactId, newGroupId, but it changes nothing.... What am I doing wrong? Any help will be highly appreciated...
Thank you very much in advance!
I am using: