brett 2003/08/20 06:08:00
Modified: src/bootstrap/org/apache/maven BootstrapTask.java
. build-bootstrap-core.xml build-bootstrap.properties
build-bootstrap.xml
xdocs/start install.xml
Log:
PR: MAVEN-470
Extra code in bootstrap to generate install_repo script. Add doco.
Revision Changes Path
1.16 +104 -3 maven/src/bootstrap/org/apache/maven/BootstrapTask.java
Index: BootstrapTask.java
===================================================================
RCS file: /home/cvs/maven/src/bootstrap/org/apache/maven/BootstrapTask.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- BootstrapTask.java 10 Jun 2003 14:16:08 -0000 1.15
+++ BootstrapTask.java 20 Aug 2003 13:08:00 -0000 1.16
@@ -56,7 +56,11 @@
* ====================================================================
*/
import java.io.File;
-
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
@@ -129,6 +133,25 @@
/** list of files to process */
private List files;
+ /** Location to put the cope_deps scripts. */
+ private File copyScriptDir = null;
+
+ /**
+ * Get the directory to put the copy script into.
+ * @return the directory
+ */
+ public File getCopyScriptDir() {
+ return copyScriptDir;
+ }
+
+ /**
+ * Set the directory to put the copy script into.
+ * @param copyScriptDir the copy script directory
+ */
+ public void setCopyScriptDir(File copyScriptDir) {
+ this.copyScriptDir = copyScriptDir;
+ }
+
/**
* Sets the projectDescriptor attribute of the BootstrapTask object
*/
@@ -313,8 +336,7 @@
for (Iterator i = dependencies.iterator(); i.hasNext(); )
{
Dependency d = (Dependency) i.next();
- String s = d.getArtifactDirectory() + "/jars/" + d.getArtifact();
- list.add(s);
+ list.add(getArtifactPath(d, "/"));
}
setFiles(list);
@@ -326,6 +348,85 @@
createClasspathReference(project, "bootstrap-classpath", list,
mavenLocalRepo);
createPatternSetReference(project, "bootstrap-patternset", list);
+ try {
+ createDependencyCopyScript();
+ } catch (IOException e) {
+ // ignore this - if the script is missing the maven script will work as
before
+ log("Problem writing copy script: " + e, Project.MSG_WARN);
+ }
+ }
+
+ /**
+ * Create the dependency copying script to avoid downloading them
+ * when running maven.
+ * @todo this should be generated through some sort of template.
+ * @throws IOException if there is a problem writing the script file
+ */
+ private void createDependencyCopyScript() throws IOException
+ {
+ if (copyScriptDir == null)
+ {
+ log("Not making the copy script - no directory given to bootstrap
task", Project.MSG_DEBUG);
+ return;
+ }
+ PrintWriter shell = new PrintWriter(new FileWriter(new File(copyScriptDir,
"install_repo.sh")));
+ shell.print("#!/bin/sh\n");
+ shell.print("REPO_DIR=$1\n");
+ shell.print("if [ -z \"$REPO_DIR\" ]; then echo \"usage: $0 [repository
directory]\"; exit; fi\n");
+ shell.print("if [ -z \"$MAVEN_HOME\" ]; then echo \"MAVEN_HOME must be
set\"; exit; fi\n");
+ PrintWriter batch = new PrintWriter(new FileWriter(new File(copyScriptDir,
"install_repo.bat")));
+ batch.print("@ECHO OFF\r\n");
+ batch.print("if \"%1\"==\"\" goto usage\r\n");
+ batch.print("set REPO_DIR=%1\r\n");
+ batch.print("if \"%MAVEN_HOME%\"==\"\" goto MHusage\r\n");
+ for (Iterator i = dependencies.iterator(); i.hasNext(); )
+ {
+ Dependency d = (Dependency) i.next();
+ String path = getArtifactPath(d, "/");
+ shell.print(
+ "if [ ! -f $REPO_DIR/"
+ + path
+ + " ]; then mkdir -p $REPO_DIR/"
+ + d.getArtifactDirectory()
+ + "/jars; cp $MAVEN_HOME/lib/");
+ if (d.getArtifactDirectory().equals("xml-apis") ||
+ d.getArtifactDirectory().equals("xerces"))
+ {
+ shell.print("endorsed/");
+ }
+ shell.print(d.getArtifact() + " $REPO_DIR/" + path + "; fi\n");
+ path = "%REPO_DIR%\\" + d.getArtifactDirectory() + "\\jars";
+ batch.print("if not exist " + path + " mkdir " + path + "\r\n");
+ path = getArtifactPath(d, "\\");
+ batch.print(
+ "if not exist \"%REPO_DIR%\\"
+ + path
+ + "\" copy \"%MAVEN_HOME%\\lib\\");
+ if (d.getArtifactDirectory().equals("xml-apis") ||
+ d.getArtifactDirectory().equals("xerces"))
+ {
+ batch.print("endorsed\\");
+ }
+ batch.print(d.getArtifact() + "\" \"%REPO_DIR%\\" + path + "\"\r\n");
+ }
+ batch.print("goto end\r\n");
+ batch.print(":MHusage\r\n");
+ batch.print("echo MAVEN_HOME must be set\r\n");
+ batch.print(":usage\r\n");
+ batch.print("echo usage: %0 [repository directory]\r\n");
+ batch.print(":end\r\n");
+ shell.close();
+ batch.close();
+ }
+
+ /**
+ * Get the artifact path for a dependency in the repository.
+ * @param d the dependency
+ * @return the path to the dependency
+ */
+ private String getArtifactPath(Dependency d, String pathSeparator)
+ {
+ return d.getArtifactDirectory() + pathSeparator + "jars" + pathSeparator +
d.getArtifact();
}
/**
1.6 +6 -2 maven/build-bootstrap-core.xml
Index: build-bootstrap-core.xml
===================================================================
RCS file: /home/cvs/maven/build-bootstrap-core.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- build-bootstrap-core.xml 19 Aug 2003 04:46:44 -0000 1.5
+++ build-bootstrap-core.xml 20 Aug 2003 13:08:00 -0000 1.6
@@ -68,6 +68,8 @@
<!-- The proxy values will be used if the values are actually set -->
+ <delete dir="${maven.bootstrap.bin.dir}"/>
+ <mkdir dir="${maven.bootstrap.bin.dir}"/>
<bootstrap
projectDescriptor="project.xml"
baseUrl="${maven.get.jars.baseUrl}/"
@@ -77,6 +79,7 @@
proxyUserName="${maven.proxy.username}"
proxyPassword="${maven.proxy.password}"
proxyPort="${maven.proxy.port}"
+ copyScriptDir="${maven.bootstrap.bin.dir}"
/>
<echo>
@@ -162,6 +165,7 @@
<copy todir="${maven.bootstrap.install.dir}/bin">
<fileset dir="src/bin"/>
+ <fileset dir="${maven.bootstrap.bin.dir}"/>
</copy>
<!-- Copy Maven's dependencies into install lib directory -->
@@ -176,12 +180,12 @@
<!-- make the endorsed dir -->
<mkdir dir="${maven.bootstrap.install.dir}/lib/endorsed" />
- <copy todir="${maven.bootstrap.install.dir}/lib/endorsed">
+ <move todir="${maven.bootstrap.install.dir}/lib/endorsed">
<fileset dir="${maven.bootstrap.install.dir}/lib">
<include name="xml-apis-*.jar" />
<include name="xerces-*.jar" />
</fileset>
- </copy>
+ </move>
<!-- Don't duplicate endorsed files -->
<delete>
1.11 +1 -0 maven/build-bootstrap.properties
Index: build-bootstrap.properties
===================================================================
RCS file: /home/cvs/maven/build-bootstrap.properties,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- build-bootstrap.properties 11 Feb 2003 17:00:08 -0000 1.10
+++ build-bootstrap.properties 20 Aug 2003 13:08:00 -0000 1.11
@@ -26,3 +26,4 @@
maven.bootstrap.phase1.classes = ${maven.bootstrap.dir}/phase1-classes
maven.bootstrap.install.dir = ${maven.bootstrap.dir}/install-phase1
+maven.bootstrap.bin.dir = ${maven.bootstrap.dir}/bin
1.205 +6 -2 maven/build-bootstrap.xml
Index: build-bootstrap.xml
===================================================================
RCS file: /home/cvs/maven/build-bootstrap.xml,v
retrieving revision 1.204
retrieving revision 1.205
diff -u -r1.204 -r1.205
--- build-bootstrap.xml 19 Aug 2003 04:46:44 -0000 1.204
+++ build-bootstrap.xml 20 Aug 2003 13:08:00 -0000 1.205
@@ -72,6 +72,8 @@
<!-- The proxy values will be used if the values are actually set -->
+ <delete dir="${maven.bootstrap.bin.dir}"/>
+ <mkdir dir="${maven.bootstrap.bin.dir}"/>
<bootstrap
projectDescriptor="project.xml"
baseUrl="${maven.get.jars.baseUrl}/"
@@ -81,6 +83,7 @@
proxyUserName="${maven.proxy.username}"
proxyPassword="${maven.proxy.password}"
proxyPort="${maven.proxy.port}"
+ copyScriptDir="${maven.bootstrap.bin.dir}"
/>
<echo>
@@ -166,6 +169,7 @@
<copy todir="${maven.bootstrap.install.dir}/bin">
<fileset dir="src/bin"/>
+ <fileset dir="${maven.bootstrap.bin.dir}"/>
</copy>
<!-- Copy Maven's dependencies into install lib directory -->
@@ -180,12 +184,12 @@
<!-- make the endorsed dir -->
<mkdir dir="${maven.bootstrap.install.dir}/lib/endorsed" />
- <copy todir="${maven.bootstrap.install.dir}/lib/endorsed">
+ <move todir="${maven.bootstrap.install.dir}/lib/endorsed">
<fileset dir="${maven.bootstrap.install.dir}/lib">
<include name="xml-apis-*.jar" />
<include name="xerces-*.jar" />
</fileset>
- </copy>
+ </move>
<!-- Don't duplicate endorsed files -->
<delete>
1.13 +8 -4 maven/xdocs/start/install.xml
Index: install.xml
===================================================================
RCS file: /home/cvs/maven/xdocs/start/install.xml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- install.xml 17 Mar 2003 18:09:21 -0000 1.12
+++ install.xml 20 Aug 2003 13:08:00 -0000 1.13
@@ -34,10 +34,14 @@
</p>
<p>
- <b>NOTE:</b> for those using Maven Beta 4 you must remove the
- definitions of ${maven.home} and ${maven.repo.local} in your
- ~/build.properties file. Maven now only requires that you set
- the $MAVEN_HOME environment variable.
+ Next, you should create your local repository by running one of the
+ following commands:
+ <source><![CDATA[
+ For Unix:
+ $MAVEN_HOME/bin/install_repo.sh $HOME/.maven/repository
+ For Windows:
+ %MAVEN_HOME%\bin\install_repo.bat %HOME%\.maven\repository
+ ]]></source>
</p>
<p>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]