You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2019/01/28 14:31:11 UTC

[GitHub] simonetripodi commented on a change in pull request #22: SLING-8253 - Make the APIs JARs source collector able to checkout SCMs if -sources artifacts are not available

simonetripodi commented on a change in pull request #22: SLING-8253 - Make the APIs JARs source collector able to checkout SCMs if -sources artifacts are not available
URL: https://github.com/apache/sling-slingfeature-maven-plugin/pull/22#discussion_r251437248
 
 

 ##########
 File path: src/main/java/org/apache/sling/feature/maven/mojos/ApisJarMojo.java
 ##########
 @@ -337,25 +357,92 @@ private void downloadSources(ArtifactId artifactId, File deflatedSourcesDir, Fil
 
                 Scm scm = pomModel.getScm();
                 if (scm == null) {
-                    throw new MojoExecutionException("SCM not defined in POM " + pomArtifactId + ", sources can not be retrieved");
+                    if (suppressSCMResolutions != null && suppressSCMResolutions.contains(pomArtifactId.toMvnId())) {
+                        getLog().warn("SCM not defined in POM " + pomArtifactId + ", sources can not be retrieved, but ignored due to the suppressSCMResolutions configuration");
+                        return;
+                    } else {
+                        throw new MojoExecutionException("SCM not defined in POM " + pomArtifactId + ", sources can not be retrieved");
+                    }
+                }
+
+                String connection = scm.getConnection();
+                String tag = scm.getTag();
+
+                if (scmRewrite != null && !scmRewrite.isEmpty()) {
+                    dance : for (Entry<Object, Object> rewrite : scmRewrite.entrySet()) {
+                        Pattern pattern = Pattern.compile((String) rewrite.getKey());
+                        Matcher matcher = pattern.matcher(connection);
+                        if (matcher.matches()) {
+                            if (matcher.groupCount() > 0) {
+                                tag = matcher.group(1);
+                            }
+
+                            connection = matcher.replaceAll((String) rewrite.getValue());
+
+                            break dance;
 
 Review comment:
   LOL this is an old joke since the College time :D

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services