You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2013/07/18 16:46:32 UTC
svn commit: r1504493 - in /httpcomponents/project-release-tools/trunk: ./
buildSrc/ buildSrc/src/main/groovy/
Author: olegk
Date: Thu Jul 18 14:46:31 2013
New Revision: 1504493
URL: http://svn.apache.org/r1504493
Log:
Improved support for checkout, update, and status SVN operations
Added:
httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnGet.groovy
- copied, changed from r1504128, httpcomponents/project-release-tools/trunk/buildSrc/build.gradle
httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy
- copied, changed from r1504128, httpcomponents/project-release-tools/trunk/buildSrc/build.gradle
Modified:
httpcomponents/project-release-tools/trunk/buildSrc/build.gradle
httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy
httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCSitePlugin.groovy
httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy
httpcomponents/project-release-tools/trunk/site.gradle
Modified: httpcomponents/project-release-tools/trunk/buildSrc/build.gradle
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/build.gradle?rev=1504493&r1=1504492&r2=1504493&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/build.gradle (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/build.gradle Thu Jul 18 14:46:31 2013
@@ -36,5 +36,6 @@ dependencies {
compile localGroovy()
compile group: 'org.ccil.cowan.tagsoup', name: 'tagsoup', version: '1.2+'
compile group: 'org.tmatesoft.svnkit', name: 'svnkit', version: '1.7+'
+ compile group: 'org.tmatesoft.svnkit', name: 'svnkit-cli', version: '1.7+'
compile group: 'org.apache.maven', name: 'maven-artifact', version: '3.0+'
}
Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy?rev=1504493&r1=1504492&r2=1504493&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCProject.groovy Thu Jul 18 14:46:31 2013
@@ -36,13 +36,16 @@ class HCProject {
public HCProject(URI repo, Project project) {
this.repo = repo
this.localDir = findLocalDir(repo, project.buildDir)
- this.pom = Mvn.parsePom(this.localDir)
+ if (!localDir.exists()) {
+ println("Checking out from SVN repository ${repo}")
+ Svn.checkout(repo, localDir)
+ }
+ this.pom = Mvn.parsePom(localDir)
}
- static File findLocalDir(URI repo, File buildDir) {
- File localDir
+ protected static File findLocalDir(URI repo, File buildDir) {
if (!repo.absolute) {
- localDir = new File(repo.toString())
+ new File(repo.toString())
} else {
String l = repo.getPath()
if (l.startsWith('/repos/asf/httpcomponents/')) {
@@ -51,13 +54,8 @@ class HCProject {
if (l.endsWith('/')) {
l = l.substring(0, l.length() - 1)
}
- localDir = new File(buildDir, l.replace('/', '-'))
- if (!localDir.exists()) {
- println("Checking out from SVN repository ${repo}")
- Svn.checkout(repo, localDir)
- }
+ new File(buildDir, l.replace('/', '-'))
}
- localDir
}
}
Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCSitePlugin.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCSitePlugin.groovy?rev=1504493&r1=1504492&r2=1504493&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCSitePlugin.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/HCSitePlugin.groovy Thu Jul 18 14:46:31 2013
@@ -35,7 +35,6 @@ import org.gradle.api.Project
* 'mvn' - Maven wrapper
* 'website' - Website project metadata
* 'publishedReleases' - Project metadata of the published releases to be added to the site
- * 'staging' - Local staging location
*/
class HCSitePlugin implements Plugin<Project> {
@@ -69,14 +68,6 @@ class HCSitePlugin implements Plugin<Pro
publishedReleases.add(new HCProject(uri, project))
}
project.extensions.add('publishedReleases', publishedReleases)
-
- String HC_SITE_STAGING = project.getProperties().get('HC_SITE_STAGING')
- if (!HC_SITE_STAGING) {
- throw InvalidUserDataException("HC_SITE_STAGING not set")
- }
- URI stagingURI = new URI(HC_SITE_STAGING)
- File staging = HCProject.findLocalDir(stagingURI, project.buildDir)
- project.extensions.add('staging', staging)
}
}
Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy?rev=1504493&r1=1504492&r2=1504493&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Svn.groovy Thu Jul 18 14:46:31 2013
@@ -25,8 +25,13 @@
*
*/
+import org.tmatesoft.svn.cli.svn.SVNCommandEnvironment
+import org.tmatesoft.svn.cli.svn.SVNNotifyPrinter
+import org.tmatesoft.svn.cli.svn.SVNStatusPrinter
import org.tmatesoft.svn.core.SVNException
import org.tmatesoft.svn.core.SVNURL
+import org.tmatesoft.svn.core.internal.wc17.SVNWCContext
+import org.tmatesoft.svn.core.internal.wc2.compat.SvnCodec
import org.tmatesoft.svn.core.wc.SVNWCUtil
import org.tmatesoft.svn.core.wc2.ISvnObjectReceiver
import org.tmatesoft.svn.core.wc2.SvnCheckout
@@ -38,51 +43,62 @@ import org.tmatesoft.svn.core.wc2.SvnUpd
class Svn {
- static void checkout(URI src, File dst) {
+ private static SVNCommandEnvironment getSVNCommandEnvironment() {
+ new SVNCommandEnvironment("SVN", System.out, System.err, System.in);
+ }
+
+ private static SvnOperationFactory createOperationFactory(SVNCommandEnvironment env) {
SvnOperationFactory opfactory = new SvnOperationFactory()
opfactory.setAuthenticationManager(SVNWCUtil.createDefaultAuthenticationManager())
+ opfactory.setEventHandler(new SVNNotifyPrinter(env))
+ opfactory
+ }
+
+ static void checkout(URI src, File dst) {
+ SVNCommandEnvironment env = getSVNCommandEnvironment()
+ SvnOperationFactory opfactory = createOperationFactory(env)
try {
- SvnCheckout checkout = opfactory.createCheckout()
- checkout.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(src.toASCIIString())))
- checkout.setSingleTarget(SvnTarget.fromFile(dst))
- checkout.run()
+ SvnCheckout checkoutOp = opfactory.createCheckout()
+ checkoutOp.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(src.toASCIIString())))
+ checkoutOp.setSingleTarget(SvnTarget.fromFile(dst))
+ checkoutOp.run()
} finally {
opfactory.dispose()
}
}
static void update(File dir) {
- SvnOperationFactory opfactory = new SvnOperationFactory()
- opfactory.setAuthenticationManager(SVNWCUtil.createDefaultAuthenticationManager())
+ SVNCommandEnvironment env = getSVNCommandEnvironment()
+ SvnOperationFactory opfactory = createOperationFactory(env)
try {
- SvnUpdate update = opfactory.createUpdate()
- update.setSingleTarget(SvnTarget.fromFile(dir))
- update.run()
+ SvnUpdate updateOp = opfactory.createUpdate()
+ updateOp.setSingleTarget(SvnTarget.fromFile(dir))
+ updateOp.run()
} finally {
opfactory.dispose()
}
}
static void status(File dir) {
- SvnOperationFactory opfactory = new SvnOperationFactory()
- opfactory.setAuthenticationManager(SVNWCUtil.createDefaultAuthenticationManager())
+ SVNCommandEnvironment env = getSVNCommandEnvironment()
+ SvnOperationFactory opfactory = createOperationFactory(env)
try {
- SvnGetStatus status = opfactory.createGetStatus()
- status.setSingleTarget(SvnTarget.fromFile(dir))
- status.setReceiver(new ISvnObjectReceiver<SvnStatus>() {
+ SVNStatusPrinter statusPrinter = new SVNStatusPrinter(env);
+ SVNWCContext context = opfactory.getWcContext();
+ SvnGetStatus statusOp = opfactory.createGetStatus()
+ statusOp.setSingleTarget(SvnTarget.fromFile(dir))
+ statusOp.setReportAll(false)
+ statusOp.setReceiver(new ISvnObjectReceiver<SvnStatus>() {
@Override
void receive(SvnTarget target, SvnStatus object) throws SVNException {
- if (target.file && target.getFile().getPath().startsWith(dir.getPath())) {
- File rel = new File(target.getFile().getPath() - dir.getPath())
- println "${object.nodeStatus} ${rel}"
- } else {
- println "${object.nodeStatus} ${target.pathOrUrlDecodedString}"
- }
+ statusPrinter.printStatus(
+ env.getRelativePath(target.getFile()),
+ SvnCodec.status(context, object), false, true, true, false)
}
})
- status.run()
+ statusOp.run()
} finally {
opfactory.dispose()
}
Copied: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnGet.groovy (from r1504128, httpcomponents/project-release-tools/trunk/buildSrc/build.gradle)
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnGet.groovy?p2=httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnGet.groovy&p1=httpcomponents/project-release-tools/trunk/buildSrc/build.gradle&r1=1504128&r2=1504493&rev=1504493&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/build.gradle (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnGet.groovy Thu Jul 18 14:46:31 2013
@@ -1,40 +1,63 @@
-/*
- * ====================================================================
- * 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. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-apply plugin: 'groovy'
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- compile gradleApi()
- compile localGroovy()
- compile group: 'org.ccil.cowan.tagsoup', name: 'tagsoup', version: '1.2+'
- compile group: 'org.tmatesoft.svnkit', name: 'svnkit', version: '1.7+'
- compile group: 'org.apache.maven', name: 'maven-artifact', version: '3.0+'
-}
+/*
+ * ====================================================================
+ * 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. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.artifacts.Configuration
+import org.gradle.api.artifacts.PublishArtifact
+import org.gradle.api.tasks.InputFiles
+import org.gradle.api.tasks.OutputFiles
+import org.gradle.api.tasks.TaskAction
+
+class SvnGet extends DefaultTask {
+
+ private URI repo
+ private File localDir
+
+ URI getRepo() {
+ return repo
+ }
+
+ void setRepo(URI repo) {
+ this.repo = repo
+ this.localDir = HCProject.findLocalDir(repo, project.buildDir)
+ }
+
+ File getLocalDir() {
+ return localDir
+ }
+
+ @TaskAction
+ void get() {
+ println("Site content source: ${repo}")
+ if (!localDir.exists()) {
+ Svn.checkout(repo, localDir)
+ } else {
+ Svn.update(localDir)
+ }
+ }
+
+}
\ No newline at end of file
Copied: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy (from r1504128, httpcomponents/project-release-tools/trunk/buildSrc/build.gradle)
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy?p2=httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy&p1=httpcomponents/project-release-tools/trunk/buildSrc/build.gradle&r1=1504128&r2=1504493&rev=1504493&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/build.gradle (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/SvnStatus.groovy Thu Jul 18 14:46:31 2013
@@ -1,40 +1,55 @@
-/*
- * ====================================================================
- * 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. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-apply plugin: 'groovy'
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- compile gradleApi()
- compile localGroovy()
- compile group: 'org.ccil.cowan.tagsoup', name: 'tagsoup', version: '1.2+'
- compile group: 'org.tmatesoft.svnkit', name: 'svnkit', version: '1.7+'
- compile group: 'org.apache.maven', name: 'maven-artifact', version: '3.0+'
-}
+/*
+ * ====================================================================
+ * 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. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.tasks.TaskAction
+
+class SvnStatus extends DefaultTask {
+
+ private URI repo
+ private File localDir
+
+ URI getRepo() {
+ return repo
+ }
+
+ void setRepo(URI repo) {
+ this.repo = repo
+ this.localDir = HCProject.findLocalDir(repo, project.buildDir)
+ }
+
+ File getLocalDir() {
+ return localDir
+ }
+
+ @TaskAction
+ void status() {
+ println("Local changes ${repo}")
+ Svn.status(localDir)
+ }
+
+}
\ No newline at end of file
Modified: httpcomponents/project-release-tools/trunk/site.gradle
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/site.gradle?rev=1504493&r1=1504492&r2=1504493&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/site.gradle (original)
+++ httpcomponents/project-release-tools/trunk/site.gradle Thu Jul 18 14:46:31 2013
@@ -42,6 +42,17 @@ task generate << {
}
}
+task prepareStage(type: SvnGet) {
+ if (!HC_SITE_STAGING) {
+ throw InvalidUserDataException("HC_SITE_STAGING not set")
+ }
+ repo = new URI(HC_SITE_STAGING)
+}
+
+task showStaged(type: SvnStatus) {
+ repo = tasks.prepareStage.repo
+}
+
task stage << {
for (HCProject release: publishedReleases) {
String releaseSeries = "${release.pom.artifactId}-${release.pom.major}.${release.pom.minor}.x"