You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by bo...@apache.org on 2015/02/20 11:52:18 UTC

svn commit: r1661086 - in /gump/live/python/gump: actor/mvnrepoproxy/proxycontrol.py core/build/gradle.py

Author: bodewig
Date: Fri Feb 20 10:52:17 2015
New Revision: 1661086

URL: http://svn.apache.org/r1661086
Log:
take the "use latest SNAPSHOT build" approach

Modified:
    gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py
    gump/live/python/gump/core/build/gradle.py

Modified: gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py?rev=1661086&r1=1661085&r2=1661086&view=diff
==============================================================================
--- gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py (original)
+++ gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py Fri Feb 20 10:52:17 2015
@@ -26,6 +26,21 @@ from gump.core.model.output import OUTPU
 from gump.core.run.actor import AbstractRunActor, FinalizeRunEvent, \
     InitializeRunEvent
 
+# list of tuples listing all snapshot repositories we want to mirror
+#   each tuple consists of a name, the path prefix that identifies the
+#   repository and the real repository URL without that prefix
+#   (properly escaped to be used in a Java .properties file).
+# Since different mvn projects use different names for the same
+#  repository it is possible to have multiple listings for a single
+#  repo.  Each name has to be unique as has to be the combination of
+#  prefix and URL (i.e. each prefix must uniquely map to a real URL)
+SNAPSHOT_PROXIES = [
+    ('apache.snapshots', '/repo/m2-snapshot-repository',
+     'http\://people.apache.org'),
+    ('sonatype-nexus-snapshots', '/content/repositories/snapshots',
+     'https\://oss.sonatype.org')
+    ]
+
 # list of tuples listing all repositories we want to mirror
 #   each tuple consists of a name, the path prefix that identifies the
 #   repository and the real repository URL without that prefix
@@ -36,12 +51,10 @@ from gump.core.run.actor import Abstract
 #  prefix and URL (i.e. each prefix must uniquely map to a real URL)
 PROXY_CONFIG = [
     ('central', '/maven2', 'http\://repo1.maven.org'),
-    ('apache.snapshots', '/repo/m2-snapshot-repository',
-     'http\://people.apache.org'),
+    SNAPSHOT_PROXIES[0],
     ('maven2-repository.dev.java.net', '/maven/2', 'http\://download.java.net'),
     ('m2.dev.java.net', '/maven/2', 'http\://download.java.net'),
-    ('sonatype-nexus-snapshots', '/content/repositories/snapshots',
-     'https\://oss.sonatype.org')
+    SNAPSHOT_PROXIES[1]
     ]
 
 class MvnRepositoryProxyController(AbstractRunActor):

Modified: gump/live/python/gump/core/build/gradle.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/core/build/gradle.py?rev=1661086&r1=1661085&r2=1661086&view=diff
==============================================================================
--- gump/live/python/gump/core/build/gradle.py (original)
+++ gump/live/python/gump/core/build/gradle.py Fri Feb 20 10:52:17 2015
@@ -19,7 +19,7 @@
 import os.path
 
 from gump import log
-from gump.actor.mvnrepoproxy.proxycontrol import PROXY_CONFIG
+from gump.actor.mvnrepoproxy.proxycontrol import SNAPSHOT_PROXIES
 from gump.core.build.mvn import local_mvn_repo
 from gump.core.model.workspace import CommandWorkItem, \
     REASON_BUILD_FAILED, REASON_BUILD_TIMEDOUT, REASON_PREBUILD_FAILED, \
@@ -37,9 +37,12 @@ from time import strftime
 # Classes
 ###############################################################################
 
-def record_proxy(init_file, port, prefix, uri):
-    init_file.write("'%s%s': 'http://localhost:%s%s',\n"\
-                    % (uri.replace('\\', ''), prefix, port, prefix))
+def record_proxy(init_file, name, prefix, uri):
+    init_file.write("""
+                maven {
+                    name "%s"
+                    url "%s%s"
+                }""" % (name, uri.replace('\\', ''), prefix))
 
 def locateGradleProjectFile(project):
     """Return Gradle project file location"""
@@ -225,7 +228,7 @@ class GradleBuilder(RunSpecific):
 
         init_file = open(init_script, 'w')
 
-        init_file.write(("""/*
+        init_file.write("""/*
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
@@ -253,60 +256,58 @@ class GradleBuilder(RunSpecific):
 #
 # DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT
 */
-import org.gradle.api.internal.artifacts.dependencies.DefaultDependencyArtifact
+import org.gradle.api.internal.artifacts.dependencies.AbstractExternalModuleDependency
 
-apply plugin:MavenRepoProxyPlugin
+apply plugin:UseLatestSnapshots
 
-class MavenRepoProxyPlugin implements Plugin<Gradle> {
-
-    private static final def REPOS_MAP = [
-""")
-                    % (project.getName(), strftime('%Y-%m-%d %H:%M:%S')))
-        if not self.run.getEnvironment().noMvnRepoProxy:
-            for (_name, prefix, url) in PROXY_CONFIG:
-                record_proxy(init_file, self.run.getWorkspace().mvnRepoProxyPort,
-                             prefix, url)
-        init_file.write("""
-    ]
+class UseLatestSnapshots implements Plugin<Gradle> {
 
     void apply(Gradle gradle) {
         gradle.allprojects{ project ->
-            project.repositories {
-                all { ArtifactRepository repo ->
-                    if (repo instanceof MavenArtifactRepository) {
-                        def newUrl = REPOS_MAP.get(stripTrailingSlash(repo.url)) ?: REPOS_MAP.get(swapTLS(repo.url))
-                        if (newUrl) {
-                            repo.url = newUrl
-                        }
-                    }
-                }
-            }
+            project.repositories {""" % (project.getName(), strftime('%Y-%m-%d %H:%M:%S')))
+        for (name, prefix, url) in SNAPSHOT_PROXIES:
+            record_proxy(init_file, name, prefix, url)
+        init_file.write("""}
             project.configurations {
                 all { config ->
-                    config.allDependencies.all { dep ->
-                        if (dep instanceof ModuleDependency && dep.artifacts.isEmpty()) {
-                            dep.addArtifact(new DefaultDependencyArtifact(dep.name, 'jar', 'jar', null, null))
+                    config.allDependencies.whenObjectAdded {
+                        if (it instanceof ExternalModuleDependency
+                            && !(it instanceof GumpExternalModuleDependency)) {
+                            config.dependencies.add(new GumpExternalModuleDependency(it))
+                            config.dependencies.remove it
                         }
                     }
                 }
             }
         }
     }
+}
 
-    def swapTLS(uri) {
-        swapScheme(uri, 'https', 'http') ?: swapScheme(uri, 'http', 'https')
+class GumpExternalModuleDependency extends AbstractExternalModuleDependency {
+    GumpExternalModuleDependency(ExternalModuleDependency dep) {
+        super(dep.group, dep.name, "latest.integration", dep.configuration)
     }
+    @Override
+    public boolean contentEquals(Dependency dependency) {
+        if (this == dependency) {
+            return true;
+        }
+        if (dependency == null || getClass() != dependency.getClass()) {
+            return false;
+        }
+
+        ExternalModuleDependency that = (ExternalModuleDependency) dependency;
+        return isContentEqualsFor(that);
 
-    def swapScheme(uri, fromScheme, toScheme) {
-        uri.scheme == fromScheme
-            ? stripTrailingSlash(new URI(toScheme, uri.schemeSpecificPart, uri.fragment))
-            : null;
     }
 
-    def stripTrailingSlash(uri) {
-        def s = uri.toString()
-        s.endsWith('/') ? s.substring(0, s.length() - 1) : s
+    @Override
+    public GumpExternalModuleDependency copy() {
+        GumpExternalModuleDependency copiedModuleDependency = new GumpExternalModuleDependency(this);
+        copyTo(copiedModuleDependency);
+        return copiedModuleDependency;
     }
+
 }
 """)
 



Re: svn commit: r1661086 - in /gump/live/python/gump: actor/mvnrepoproxy/proxycontrol.py core/build/gradle.py

Posted by Stefan Bodewig <bo...@apache.org>.
On 2015-02-20, Konstantin Kolinko wrote:

> 2015-02-20 13:52 GMT+03:00  <bo...@apache.org>:

>>+ SNAPSHOT_PROXIES = [
>>+    ('apache.snapshots', '/repo/m2-snapshot-repository',
>>+     'http\://people.apache.org'),

> Is the above repository still useful?

Don't know.  Gump has been using it for a long time and we've never
changed it.

> If I go to http://people.apache.org/repo/m2-snapshot-repository/
> there is a NOTE text there that says:

> "Some projects have moved their snapshots to a new repository at
> http://repository.apache.org/snapshots. You should update your Maven
> builds to use the new repository url since the contents of this
> repository is also proxied and aggregated at the new url."

I'll change the entry.

Thanks!

        Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@gump.apache.org
For additional commands, e-mail: general-help@gump.apache.org


Re: svn commit: r1661086 - in /gump/live/python/gump: actor/mvnrepoproxy/proxycontrol.py core/build/gradle.py

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-02-20 13:52 GMT+03:00  <bo...@apache.org>:
> Author: bodewig
> Date: Fri Feb 20 10:52:17 2015
> New Revision: 1661086
>
> URL: http://svn.apache.org/r1661086
> Log:
> take the "use latest SNAPSHOT build" approach
>
> Modified:
>     gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py
>     gump/live/python/gump/core/build/gradle.py
>
> Modified: gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py
> URL: http://svn.apache.org/viewvc/gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py?rev=1661086&r1=1661085&r2=1661086&view=diff
> ==============================================================================
> --- gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py (original)
> +++ gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py Fri Feb 20 10:52:17 2015
> @@ -26,6 +26,21 @@ from gump.core.model.output import OUTPU
>  from gump.core.run.actor import AbstractRunActor, FinalizeRunEvent, \
>      InitializeRunEvent
>
> +# list of tuples listing all snapshot repositories we want to mirror
> +#   each tuple consists of a name, the path prefix that identifies the
> +#   repository and the real repository URL without that prefix
> +#   (properly escaped to be used in a Java .properties file).
> +# Since different mvn projects use different names for the same
> +#  repository it is possible to have multiple listings for a single
> +#  repo.  Each name has to be unique as has to be the combination of
> +#  prefix and URL (i.e. each prefix must uniquely map to a real URL)
> +SNAPSHOT_PROXIES = [
> +    ('apache.snapshots', '/repo/m2-snapshot-repository',
> +     'http\://people.apache.org'),

Is the above repository still useful?

If I go to http://people.apache.org/repo/m2-snapshot-repository/
there is a NOTE text there that says:

"Some projects have moved their snapshots to a new repository at
http://repository.apache.org/snapshots. You should update your Maven
builds to use the new repository url since the contents of this
repository is also proxied and aggregated at the new url."



> +    ('sonatype-nexus-snapshots', '/content/repositories/snapshots',
> +     'https\://oss.sonatype.org')
> +    ]
> +
>  # list of tuples listing all repositories we want to mirror
>  #   each tuple consists of a name, the path prefix that identifies the
>  #   repository and the real repository URL without that prefix
> @@ -36,12 +51,10 @@ from gump.core.run.actor import Abstract
>  #  prefix and URL (i.e. each prefix must uniquely map to a real URL)
>  PROXY_CONFIG = [
>      ('central', '/maven2', 'http\://repo1.maven.org'),
> -    ('apache.snapshots', '/repo/m2-snapshot-repository',
> -     'http\://people.apache.org'),
> +    SNAPSHOT_PROXIES[0],
>      ('maven2-repository.dev.java.net', '/maven/2', 'http\://download.java.net'),
>      ('m2.dev.java.net', '/maven/2', 'http\://download.java.net'),
> -    ('sonatype-nexus-snapshots', '/content/repositories/snapshots',
> -     'https\://oss.sonatype.org')
> +    SNAPSHOT_PROXIES[1]
>      ]
>
>  class MvnRepositoryProxyController(AbstractRunActor):
>
> <...>

Best regards,
Konstantin Kolinko

Re: svn commit: r1661086 - in /gump/live/python/gump: actor/mvnrepoproxy/proxycontrol.py core/build/gradle.py

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-02-20 13:52 GMT+03:00  <bo...@apache.org>:
> Author: bodewig
> Date: Fri Feb 20 10:52:17 2015
> New Revision: 1661086
>
> URL: http://svn.apache.org/r1661086
> Log:
> take the "use latest SNAPSHOT build" approach
>
> Modified:
>     gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py
>     gump/live/python/gump/core/build/gradle.py
>
> Modified: gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py
> URL: http://svn.apache.org/viewvc/gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py?rev=1661086&r1=1661085&r2=1661086&view=diff
> ==============================================================================
> --- gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py (original)
> +++ gump/live/python/gump/actor/mvnrepoproxy/proxycontrol.py Fri Feb 20 10:52:17 2015
> @@ -26,6 +26,21 @@ from gump.core.model.output import OUTPU
>  from gump.core.run.actor import AbstractRunActor, FinalizeRunEvent, \
>      InitializeRunEvent
>
> +# list of tuples listing all snapshot repositories we want to mirror
> +#   each tuple consists of a name, the path prefix that identifies the
> +#   repository and the real repository URL without that prefix
> +#   (properly escaped to be used in a Java .properties file).
> +# Since different mvn projects use different names for the same
> +#  repository it is possible to have multiple listings for a single
> +#  repo.  Each name has to be unique as has to be the combination of
> +#  prefix and URL (i.e. each prefix must uniquely map to a real URL)
> +SNAPSHOT_PROXIES = [
> +    ('apache.snapshots', '/repo/m2-snapshot-repository',
> +     'http\://people.apache.org'),

Is the above repository still useful?

If I go to http://people.apache.org/repo/m2-snapshot-repository/
there is a NOTE text there that says:

"Some projects have moved their snapshots to a new repository at
http://repository.apache.org/snapshots. You should update your Maven
builds to use the new repository url since the contents of this
repository is also proxied and aggregated at the new url."



> +    ('sonatype-nexus-snapshots', '/content/repositories/snapshots',
> +     'https\://oss.sonatype.org')
> +    ]
> +
>  # list of tuples listing all repositories we want to mirror
>  #   each tuple consists of a name, the path prefix that identifies the
>  #   repository and the real repository URL without that prefix
> @@ -36,12 +51,10 @@ from gump.core.run.actor import Abstract
>  #  prefix and URL (i.e. each prefix must uniquely map to a real URL)
>  PROXY_CONFIG = [
>      ('central', '/maven2', 'http\://repo1.maven.org'),
> -    ('apache.snapshots', '/repo/m2-snapshot-repository',
> -     'http\://people.apache.org'),
> +    SNAPSHOT_PROXIES[0],
>      ('maven2-repository.dev.java.net', '/maven/2', 'http\://download.java.net'),
>      ('m2.dev.java.net', '/maven/2', 'http\://download.java.net'),
> -    ('sonatype-nexus-snapshots', '/content/repositories/snapshots',
> -     'https\://oss.sonatype.org')
> +    SNAPSHOT_PROXIES[1]
>      ]
>
>  class MvnRepositoryProxyController(AbstractRunActor):
>
> <...>

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@gump.apache.org
For additional commands, e-mail: general-help@gump.apache.org