@@ -43,6 +43,8 @@ public class RepositoryTransformersExtension {
4343
4444 private static final String REPOSITORIES_MARKER = "{spring.mavenRepositories}" ;
4545
46+ private static final String PLUGIN_REPOSITORIES_MARKER = "{spring.mavenPluginRepositories}" ;
47+
4648 private final Project project ;
4749
4850 @ Inject
@@ -67,13 +69,33 @@ private String transformAnt(String line) {
6769 getSpringRepositories ().forEach ((repository ) -> {
6870 if (repository .getName ().startsWith ("spring-commercial-" )) {
6971 String host = repository .getUrl ().getHost ();
70- hostCredentials .put (host ,
71- new MavenCredential ("${env.COMMERCIAL_REPO_USERNAME}" , "${env.COMMERCIAL_REPO_PASSWORD}" ));
72+ hostCredentials .put (host , new MavenCredential ("${env.COMMERCIAL_REPO_USERNAME}" ,
73+ "${env.COMMERCIAL_REPO_PASSWORD}" , "Artifactory Realm" ));
74+ }
75+ else if (repository .getName ().equals ("spring-release-train" )) {
76+ String host = repository .getUrl ().getHost ();
77+ hostCredentials .put (host , new MavenCredential ("${env.RELEASE_TRAIN_MAVEN_REPOSITORY_USERNAME}" ,
78+ "${env.RELEASE_TRAIN_MAVEN_REPOSITORY_PASSWORD}" , "GitHub Package Registry" ));
7279 }
7380 });
74- return transform (line , hostCredentials .entrySet (), (entry ,
75- indent ) -> "%s<credentials host=\" %s\" realm=\" Artifactory Realm\" username=\" %s\" passwd=\" %s\" />%n"
76- .formatted (indent , entry .getKey (), entry .getValue ().username (), entry .getValue ().password ()));
81+ return transform (line , hostCredentials .entrySet (),
82+ (entry , indent ) -> "%s<credentials host=\" %s\" realm=\" %s\" username=\" %s\" passwd=\" %s\" />%n"
83+ .formatted (indent , entry .getKey (), entry .getValue ().realm (), entry .getValue ().username (),
84+ entry .getValue ().password ()));
85+ }
86+ return line ;
87+ }
88+
89+ public Transformer <String , String > mavenSettings () {
90+ return this ::transformMavenSettings ;
91+ }
92+
93+ private String transformMavenSettings (String line ) {
94+ if (line .contains (REPOSITORIES_MARKER )) {
95+ return transformMavenRepositories (line , false );
96+ }
97+ if (line .contains (PLUGIN_REPOSITORIES_MARKER )) {
98+ return transformMavenRepositories (line , true );
7799 }
78100 return line ;
79101 }
@@ -141,7 +163,7 @@ static void apply(Project project) {
141163 project .getExtensions ().create ("springRepositoryTransformers" , RepositoryTransformersExtension .class , project );
142164 }
143165
144- record MavenCredential (String username , String password ) {
166+ record MavenCredential (String username , String password , String realm ) {
145167
146168 }
147169
0 commit comments