diff --git a/xdoc/project.xml b/xdoc/project.xml index 80ff49ce..a393bd08 100644 --- a/xdoc/project.xml +++ b/xdoc/project.xml @@ -268,5 +268,25 @@ This library is already loaded by maven's core. Be careful to use the same version number as in the core. + + org.apache.maven.scm + maven-scm-api + 1.0-beta-2 + + + org.apache.maven.scm + maven-scm-provider-perforce + 1.0-beta-2 + + + org.apache.maven.scm + maven-scm-provider-clearcase + 1.0-beta-2 + + + org.apache.maven.scm + maven-scm-provider-starteam + 1.0-beta-2 + diff --git a/xdoc/src/main/org/apache/maven/xdoc/util/ScmUtil.java b/xdoc/src/main/org/apache/maven/xdoc/util/ScmUtil.java index 837159dc..efe4f822 100644 --- a/xdoc/src/main/org/apache/maven/xdoc/util/ScmUtil.java +++ b/xdoc/src/main/org/apache/maven/xdoc/util/ScmUtil.java @@ -20,6 +20,19 @@ package org.apache.maven.xdoc.util; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang.StringUtils; + +import org.apache.maven.scm.manager.NoSuchScmProviderException; +import org.apache.maven.scm.manager.ScmManager; +import org.apache.maven.scm.provider.clearcase.ClearCaseScmProvider; +import org.apache.maven.scm.provider.clearcase.repository.ClearCaseScmProviderRepository; +import org.apache.maven.scm.provider.perforce.PerforceScmProvider; +import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository; +import org.apache.maven.scm.provider.starteam.StarteamScmProvider; +import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository; +import org.apache.maven.scm.repository.ScmRepository; +import org.apache.maven.scm.repository.ScmRepositoryException; + import org.apache.maven.util.EnhancedStringTokenizer; /** @@ -118,6 +131,139 @@ public final class ScmUtil return null; } + /** + * Create the documentation to provide an developer access with a Perforce SCM. + * For example, generate the following command line: + *

p4 -H hostname -p port -u username -P password path

+ *

p4 -H hostname -p port -u username -P password path submit -c changement

+ * + * @param perforceRepo + * @see http://www.perforce.com/perforce/doc.051/manuals/cmdref/index.html + */ + public String developerAccessPerforce( String devConnection ) + { + StringBuffer command = new StringBuffer(); + char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 ); + + PerforceScmProvider perforceProvider= new PerforceScmProvider(); + PerforceScmProviderRepository perforceRepo; + + String scmSpecificUrl = devConnection.substring( 13 ); + + try + { + perforceRepo = (PerforceScmProviderRepository) + perforceProvider.makeProviderScmRepository( scmSpecificUrl, delim ); + } + catch (ScmRepositoryException e) + { + System.err.println( "Your developerConnection does not seem to be valid: " + e.getMessage() ); + return ""; + } + + + command.append( "p4" ); + if ( !StringUtils.isEmpty( perforceRepo.getHost() ) ) + { + command.append( " -H " ).append( perforceRepo.getHost() ); + } + if ( perforceRepo.getPort() > 0 ) + { + command.append( " -p " + perforceRepo.getPort() ); + } + command.append( " -u username" ); + command.append( " -P password" ); + command.append( " " ); + command.append( perforceRepo.getPath() ); + command.append( "\n" ); + command.append( "p4 submit -c \"A comment\"" ); + + return command.toString(); + } + + // Starteam + + /** + * Create the documentation to provide an developer access with a Starteam SCM. + * For example, generate the following command line: + *

stcmd co -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl -is

+ *

stcmd ci -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl -f NCI -is

+ * + * @param starteamRepo + */ + public String developerAccessStarteam( String devConnection ) + { + + StringBuffer command = new StringBuffer(); + char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 ); + + StarteamScmProvider starteamProvider= new StarteamScmProvider(); + StarteamScmProviderRepository starteamRepo; + + String scmSpecificUrl = devConnection.substring( 13 ); + + try + { + starteamRepo = (StarteamScmProviderRepository) + starteamProvider.makeProviderScmRepository( scmSpecificUrl, delim ); + } + catch (ScmRepositoryException e) + { + System.err.println( "Your developerConnection does not seem to be valid: " + e.getMessage() ); + return ""; + } + + // Safety: remove the username/password if present + String fullUrl = StringUtils.replace( starteamRepo.getFullUrl(), starteamRepo.getUser(), "username" ); + fullUrl = StringUtils.replace( fullUrl, starteamRepo.getPassword(), "password" ); + + command.append( "stcmd co -x -nologo -stop -p " ); + command.append( fullUrl ); + command.append( " -is" ); + command.append( "\n" ); + command.append( "stcmd ci -x -nologo -stop -p " ); + command.append( fullUrl ); + command.append( " -f NCI -is" ); + + return command.toString(); + } + + + /** + * Create the documentation to provide an developer access with a Clearcase SCM. + * For example, generate the following command line: + *

cleartool checkout module

+ * + * @param clearCaseRepo + */ + public String developerAccessClearCase( String devConnection ) + { + + StringBuffer command = new StringBuffer(); + char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 ); + + ClearCaseScmProvider clearCaseProvider= new ClearCaseScmProvider(); + ClearCaseScmProviderRepository clearCaseRepo; + + String scmSpecificUrl = devConnection.substring( 14 ); + + try + { + clearCaseRepo = (ClearCaseScmProviderRepository) + clearCaseProvider.makeProviderScmRepository( scmSpecificUrl, delim ); + } + catch (ScmRepositoryException e) + { + System.err.println( "Your developerConnection does not seem to be valid: " + e.getMessage() ); + return ""; + } + + command.append( "cleartool checkout " ).append( clearCaseRepo.getViewName( "id" ) ); + + return command.toString(); + } + + /** * Splits an SCM string into parts. * diff --git a/xdoc/src/plugin-resources/templates/scm/clearcase.xml b/xdoc/src/plugin-resources/templates/scm/clearcase.xml index 2c4b7443..8cc4bfee 100644 --- a/xdoc/src/plugin-resources/templates/scm/clearcase.xml +++ b/xdoc/src/plugin-resources/templates/scm/clearcase.xml @@ -1,11 +1,42 @@ -
-

- This section is under construction. -

-
+
+

+ + Clearcase + + http://www.redbooks.ibm.com/redbooks/pdfs/sg246399.pdf. +

+ + #if ($repository.developerConnection && $repository.developerConnection != '') + #set ($command = $scmUtil.developerAccessClearCase($repository.developerConnection)) + + + +

+ +

+ + $command + +
+ + + +

+ +

+ +
+ + #end -
-

- This section is under construction. -

diff --git a/xdoc/src/plugin-resources/templates/scm/perforce.xml b/xdoc/src/plugin-resources/templates/scm/perforce.xml index 29d08c29..87dcd8b2 100644 --- a/xdoc/src/plugin-resources/templates/scm/perforce.xml +++ b/xdoc/src/plugin-resources/templates/scm/perforce.xml @@ -1,11 +1,42 @@ -
-

- This section is under construction. -

-
+
+

+ + Perforce + + http://www.perforce.com/perforce/doc.051/manuals/cmdref/index.html. +

-
-

- This section is under construction. -

-
\ No newline at end of file + #if ($repository.developerConnection && $repository.developerConnection != '') + #set ($command = $scmUtil.developerAccessPerforce($repository.developerConnection)) + + + +

+ +

+ + $command + +
+ + + +

+ +

+ +
+ + #end + +
diff --git a/xdoc/src/plugin-resources/templates/scm/starteam.xml b/xdoc/src/plugin-resources/templates/scm/starteam.xml index dd11ea59..db021069 100644 --- a/xdoc/src/plugin-resources/templates/scm/starteam.xml +++ b/xdoc/src/plugin-resources/templates/scm/starteam.xml @@ -1,11 +1,41 @@ -
-

- This section is under construction. -

-
+
+

+ + Starteam + . +

-
-

- This section is under construction. -

-
\ No newline at end of file + #if ($repository.developerConnection && $repository.developerConnection != '') + #set ($command = $scmUtil.developerAccessStarteam($repository.developerConnection)) + + + +

+ +

+ + $command + +
+ + + +

+ +

+ +
+ + #end + +
diff --git a/xdoc/src/plugin-resources/templates/templates.properties b/xdoc/src/plugin-resources/templates/templates.properties index 6210a1a7..3dcc25da 100644 --- a/xdoc/src/plugin-resources/templates/templates.properties +++ b/xdoc/src/plugin-resources/templates/templates.properties @@ -64,6 +64,25 @@ template.svn.section8.intro1=The Subversion client can go through a proxy, if yo template.svn.section8.intro2=There are comments in the file explaining what to do. If you don't have that file, get the latest Subversion client and run any command; this will cause the configuration directory and template files to be created. template.svn.section8.intro3=Example : Edit the 'servers' file and add something like: +# For clearcase.xml +template.clearcase.section2.part2=to manage its source code. Instructions for using ClearCase can be found at +template.clearcase.section6.description=Only project developers can access the ClearCase tree via this method. Substitute username with the proper value. + +# For perforce.xml +template.perforce.section2.part2=to manage its source code. Instructions for using Perforce can be found at +template.perforce.section6.description=Only project developers can access the Perforce tree via this method. Substitute username and password with the proper values. + +# For starteam.xml +template.starteam.section2.part2=to manage its source code. +template.starteam.section6.description=Only project developers can access the Starteam tree via this method. Substitute username and password with the proper values. + +# Used by clearcase.xml, perforce.xml, starteam.xml +template.scm.section2.title=Source Repository +template.scm.section2.part1=This project uses +template.scm.section6.title=Developer Access +template.scm.accessbehindfirewall.title=Access from behind a firewall +template.scm.accessbehindfirewall.general.intro=Refer to the documentation of the SCM used for more information about an access behind a firewall. + # For dependencies.xml template.dependencies.title=Dependencies template.dependencies.section.title=Dependencies diff --git a/xdoc/src/plugin-resources/templates/templates_de.properties b/xdoc/src/plugin-resources/templates/templates_de.properties index 1bd91ddb..9d079406 100644 --- a/xdoc/src/plugin-resources/templates/templates_de.properties +++ b/xdoc/src/plugin-resources/templates/templates_de.properties @@ -54,9 +54,9 @@ template.svn.section3.description=Das Quellcode Archiv dieses Projektes kann dur template.svn.section4.title=Anonymer Zugriff template.svn.section4.description=Das Quellcode Archiv dieses Projektes kann mit dem folgenden Befehl ausgecheckt werden: template.svn.section5.title=Entwickler Zugriff mit Maven -template.svn.section5.description=Even though everyone can checkout the Subversion repository via HTTPS, committers have to use HTTPS if they want to be able to check back in their changes. Use the following instruction set on a single line: +template.svn.section5.description=Jeder kann auf das Subversion Archiv via HTTPS zugreifen, aber Entwickler müssen es verwenden, wenn sie ihre Änderungen wider ein-checken wollen. Verwenden Sie die folgenden Instruktionen auf einer Linie: template.svn.section6.title=Entwickler Zugriff -template.svn.section6.description=Even though everyone can checkout the Subversion repository via HTTPS, committers have to use HTTPS if they want to be able to check back in their changes. Use the following command: +template.svn.section6.description=Jeder kann auf das Subversion Archiv via HTTPS zugreifen, aber Entwickler müssen es verwenden, wenn sie ihre Änderungen wider ein-checken wollen. Verwenden Sie den folgenden Befehl: template.svn.section7.title=Zugriff hinter einer Firewall template.svn.section7.description=Entwickler die sich hinter einer Firewall befinden die den http Zugriff auf das Quellcode Archiv blockiert, sollten versuchen über die Entwickler-Verbindung darauf zuzugreifen: template.svn.section8.title=Zugriff über einen Proxy @@ -65,6 +65,25 @@ verwendenden Proxy angeben. Es h template.svn.section8.intro2=Diese Datei enthält einige Gebrauchshinweise. Sollte diese Datei nicht existieren, verwenden Sie die neueste Version von Subversion und exekutieren Sie irgend einen Befehl. Die Datei wird dann automatisch erzeugt. template.svn.section8.intro3=Beispiel: Editieren Sie die "servers" Datei und fügen Sie hinzu: +# For clearcase.xml +template.clearcase.section2.part2=um seinen Quellcode zu verwalten. Instruktionen zur Verwendung von ClearCase finden Sie hier: +template.clearcase.section6.description=Nur Entwickler können auf das ClearCase Quellcode Archiv mit dieser Methode zugreifen. Ersetzen Sie den Benutzernamen ("username") durch Ihren eigenen. + +# For perforce.xml +template.perforce.section2.part2=um seinen Quellcode zu verwalten. Instruktionen zur Verwendung von Perforce finden Sie hier: +template.perforce.section6.description=Nur Entwickler können auf das Perforce Quellcode Archiv mit dieser Methode zugreifen. Ersetzen Sie den Benutzernamen ("username") und 'password' mit den entsprechenden Werten. + +# For starteam.xml +template.starteam.section2.part2=um seinen Quellcode zu verwalten. +template.starteam.section6.description=Nur Entwickler können auf das Perforce Quellcode Archiv mit dieser Methode zugreifen. Ersetzen Sie den Benutzernamen ("username") und 'password' mit den entsprechenden Werten. + +# Used by clearcase.xml, perforce.xml, starteam.xml +template.scm.section2.title=Quellcode Archiv +template.scm.section2.part1=Dieses Projekt verwendet +template.scm.section6.title=Entwickler Zugriff +template.scm.accessbehindfirewall.title=Zugriff hinter einer Firewall +template.scm.accessbehindfirewall.general.intro=Konsultieren Sie die Gebrauchshinweisungen Ihres SCM's für Information über Zugriff hinter einer Firewall. + # For dependencies.xml template.dependencies.title = Abhängigkeiten template.dependencies.section.title = Abhängigkeiten diff --git a/xdoc/src/plugin-resources/templates/templates_fr.properties b/xdoc/src/plugin-resources/templates/templates_fr.properties index e4e8092c..1f12b88e 100644 --- a/xdoc/src/plugin-resources/templates/templates_fr.properties +++ b/xdoc/src/plugin-resources/templates/templates_fr.properties @@ -65,6 +65,25 @@ pour indiquer quel proxy utilis template.svn.section8.intro2=Il y a des commentaires dans le fichier qui explique comment faire. Si vous n'avez pas ce fichier, télécharger la version la plus récente de Subversion et tapez n'importe quelle commande ; ceci créera les fichiers de configuration. template.svn.section8.intro3=Exemple : Editer le fichier 'servers' et ajouter quelque chose du genre: +# For clearcase.xml +template.clearcase.section2.part2=pour gérer son code source. Des instructions sur l'utilisation de ClearCase peuvent être trouvées à +template.clearcase.section6.description=Seulement les dévelopeurs du projet peuvent accéder à l'arbre de ClearCase par l'intermédiaire de cette méthode. Remplacez username avec la valeur appropriée. + +# For perforce.xml +template.perforce.section2.part2=pour gérer son code source. Des instructions sur l'utilisation de Perforce peuvent être trouvées à +template.perforce.section6.description=Seulement les dévelopeurs du projet peuvent accéder à l'arbre de ClearCase par l'intermédiaire de cette méthode. Remplacez username et password avec les valeurs appropriées. + +# For starteam.xml +template.starteam.section2.part2=tpour gérer son code source. +template.starteam.section6.description=Seulement les dévelopeurs du projet peuvent accéder à l'arbre de Starteam par l'intermédiaire de cette méthode. Remplacez username et password avec les valeurs appropriées. + +# Used by clearcase.xml, perforce.xml, starteam.xml +template.scm.section2.title=Dépôt de sources +template.scm.section2.part1=Ce projet utilise +template.scm.section6.title=Accès pour les dévelopeurs +template.scm.accessbehindfirewall.title=Accès derrière un firewall +template.scm.accessbehindfirewall.general.intro=Référez-vous à la documentation du dépôt d'archive utilisé pour plus d'informations sur l'accès derrière un firewall. + # For dependencies.xml template.dependencies.title=Dépendances template.dependencies.section.title=Dépendances diff --git a/xdoc/src/test/org/apache/maven/xdoc/util/ScmUtilTest.java b/xdoc/src/test/org/apache/maven/xdoc/util/ScmUtilTest.java index 3aa2a1db..8807322b 100644 --- a/xdoc/src/test/org/apache/maven/xdoc/util/ScmUtilTest.java +++ b/xdoc/src/test/org/apache/maven/xdoc/util/ScmUtilTest.java @@ -32,6 +32,15 @@ public class ScmUtilTest extends TestCase private final String cvs2 = "scm:cvs:ext:username@cvs.apache.org:/cvs/root:module"; private final String svn = "scm:svn:http://svn.apache.org/svn/root/module"; + private final String perforce1 = + "scm:perforce:john_doe@somehost:21:path_to_repository"; + private final String perforce2 = "scm:perforce://depot/modules/myproject"; + private final String starteam1 = + "scm:starteam:john_doe:secret_password@myhost:23456/project/view/folder"; + private final String starteam2 = + "scm:starteam:john_doe@myhost:23456/project/view/folder"; + private final String clearcase = + "scm:clearcase:my_module_view://myserver/clearcase/configspecs/my_module.txt"; private final String invalid = ""; public void testSCMConnectionSeparator() @@ -68,4 +77,30 @@ public class ScmUtilTest extends TestCase "scm:cvs:ext:john_doe@cvs.apache.org:/cvs/root:module" ); assertEquals( scmUtil.getCvsConnection( svn, "" ), "" ); } + + public void testDeveloperAccessPerforce() + { + assertEquals( scmUtil.developerAccessPerforce( perforce1 ), + "p4 -H somehost -p 21 -u username -P password path_to_repository\np4 submit -c \"A comment\"" ); + assertEquals( scmUtil.developerAccessPerforce( perforce2 ), + "p4 -u username -P password //depot/modules/myproject\np4 submit -c \"A comment\"" ); + } + +// TODO: FIXME: why does this fail with a NoClassDefFoundError? +/* + public void testDeveloperAccessStarteam() + { + assertEquals( scmUtil.developerAccessStarteam( starteam1 ), + "stcmd co -x -nologo -stop -p username:password@myhost:23456/project/view/folder -is\nstcmd ci -x -nologo -stop -p username:password@myhost:23456/project/view/folder -f NCI -is" ); + assertEquals( scmUtil.developerAccessStarteam( starteam2 ), + "stcmd co -x -nologo -stop -p username:@myhost:23456/project/view/folder -is\nstcmd ci -x -nologo -stop -p username:@myhost:23456/project/view/folder -f NCI -is" ); + } +*/ + + public void testDeveloperAccessClearCase() + { + assertEquals( scmUtil.developerAccessClearCase( clearcase ), + "cleartool checkout my_module_view" ); + } + } diff --git a/xdoc/xdocs/changes.xml b/xdoc/xdocs/changes.xml index ddcb8d87..20eb20ce 100644 --- a/xdoc/xdocs/changes.xml +++ b/xdoc/xdocs/changes.xml @@ -27,6 +27,7 @@ + Include instructions for ClearCase, Starteam and Perforce access in the scm-usage page. xdoc:init was called six times during one xdoc run. Include dependencies' scope in dependencies page. Include the new theme maven-stylus.css.