You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm-commits@maven.apache.org by ev...@apache.org on 2006/03/01 12:16:38 UTC
svn commit: r381987 [10/13] - in
/maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs: ./
maven-scm-provider-cvs-commons/ maven-scm-provider-cvs-commons/src/
maven-scm-provider-cvs-commons/src/main/
maven-scm-provider-cvs-commons/src/main/java/...
Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvstest/src/main/resources/repository/test-repo/changelog/src/java/org/apache/maven/MavenUtils.java,v
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvstest/src/main/resources/repository/test-repo/changelog/src/java/org/apache/maven/MavenUtils.java%2Cv?rev=381987&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvstest/src/main/resources/repository/test-repo/changelog/src/java/org/apache/maven/MavenUtils.java,v (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-cvs/maven-scm-provider-cvstest/src/main/resources/repository/test-repo/changelog/src/java/org/apache/maven/MavenUtils.java,v Wed Mar 1 03:16:02 2006
@@ -0,0 +1,8356 @@
+head 1.111;
+access;
+symbols
+ MAVEN_1_0:1.107.4.22
+ MAVEN_1_0_RC4:1.107.4.21
+ MAVEN_1_0_RC3:1.107.4.20
+ MAVEN-1_0-BRANCH-merge-3:1.107.4.20
+ MAVEN_1_0_RC2:1.107.4.12
+ MAVEN-1_0-BRANCH-merge-2:1.107.4.8
+ MAVEN-1_0-BRANCH-merge-1:1.107.4.8
+ MAVEN-1_0-BRANCH:1.107.0.4
+ MAVEN_RC2_UNSTABLE-merge-1:1.107
+ MAVEN_RC2_UNSTABLE:1.107.0.2
+ MAVEN_1_0_RC1:1.105
+ MAVEN_RC1_REFACTOR:1.98.0.2
+ MAVEN_POST_RC1_REFACTOR:1.98
+ MAVEN_RC1_STABLE:1.94.0.2
+ BRW_TEST:1.97.0.2
+ MAVEN_PRE_RC1_REFACTOR:1.94
+ MAVEN_1_0_B10:1.94
+ MAVEN_1_0_B9:1.91
+ MAVEN_1_0_B8:1.88
+ SAFE_31_DEC_2002:1.79
+ SAFE_31_OCT_2002:1.49
+ MAVEN_1_0_B7:1.45
+ MAVEN_1_0_B6:1.41
+ MAVEN_1_0_B5:1.37
+ MAVEN_1_0_B4:1.20
+ pre_callbacks:1.15
+ MAVEN_1_0_B3:1.9
+ MAVEN_1_0_B2:1.6
+ MAVEN_1_0_B1:1.3;
+locks; strict;
+comment @# @;
+
+
+1.111
+date 2004.06.28.15.09.13; author brett; state Exp;
+branches;
+next 1.110;
+
+1.110
+date 2004.05.05.13.05.52; author brett; state Exp;
+branches;
+next 1.109;
+
+1.109
+date 2004.03.23.02.18.18; author brett; state Exp;
+branches;
+next 1.108;
+
+1.108
+date 2004.02.07.22.46.15; author brett; state Exp;
+branches;
+next 1.107;
+
+1.107
+date 2003.10.17.01.08.02; author dion; state Exp;
+branches
+ 1.107.2.1
+ 1.107.4.1;
+next 1.106;
+
+1.106
+date 2003.10.16.08.53.42; author dion; state Exp;
+branches;
+next 1.105;
+
+1.105
+date 2003.09.04.00.36.04; author dion; state Exp;
+branches;
+next 1.104;
+
+1.104
+date 2003.09.02.12.55.12; author evenisse; state Exp;
+branches;
+next 1.103;
+
+1.103
+date 2003.09.02.10.28.28; author evenisse; state Exp;
+branches;
+next 1.102;
+
+1.102
+date 2003.09.01.06.56.58; author dion; state Exp;
+branches;
+next 1.101;
+
+1.101
+date 2003.09.01.05.34.08; author dion; state Exp;
+branches;
+next 1.100;
+
+1.100
+date 2003.09.01.00.34.40; author dion; state Exp;
+branches;
+next 1.99;
+
+1.99
+date 2003.08.19.04.31.38; author dion; state Exp;
+branches;
+next 1.98;
+
+1.98
+date 2003.08.06.05.05.23; author dion; state Exp;
+branches;
+next 1.97;
+
+1.97
+date 2003.07.29.01.04.36; author dion; state Exp;
+branches;
+next 1.96;
+
+1.96
+date 2003.07.29.00.17.50; author dion; state Exp;
+branches;
+next 1.95;
+
+1.95
+date 2003.07.27.23.33.56; author jvanzyl; state Exp;
+branches;
+next 1.94;
+
+1.94
+date 2003.06.07.01.27.52; author jvanzyl; state Exp;
+branches
+ 1.94.2.1;
+next 1.93;
+
+1.93
+date 2003.04.12.00.02.04; author dion; state Exp;
+branches;
+next 1.92;
+
+1.92
+date 2003.04.11.09.03.09; author abarantsev; state Exp;
+branches;
+next 1.91;
+
+1.91
+date 2003.03.24.13.55.28; author dion; state Exp;
+branches;
+next 1.90;
+
+1.90
+date 2003.03.08.02.31.36; author bwalding; state Exp;
+branches;
+next 1.89;
+
+1.89
+date 2003.02.21.07.03.33; author dion; state Exp;
+branches;
+next 1.88;
+
+1.88
+date 2003.02.10.13.55.00; author jvanzyl; state Exp;
+branches;
+next 1.87;
+
+1.87
+date 2003.01.24.05.21.36; author jvanzyl; state Exp;
+branches;
+next 1.86;
+
+1.86
+date 2003.01.24.03.50.37; author jvanzyl; state Exp;
+branches;
+next 1.85;
+
+1.85
+date 2003.01.08.20.25.57; author jvanzyl; state Exp;
+branches;
+next 1.84;
+
+1.84
+date 2003.01.07.03.13.53; author jvanzyl; state Exp;
+branches;
+next 1.83;
+
+1.83
+date 2003.01.02.10.56.52; author dion; state Exp;
+branches;
+next 1.82;
+
+1.82
+date 2003.01.02.10.56.02; author dion; state Exp;
+branches;
+next 1.81;
+
+1.81
+date 2003.01.02.07.25.00; author jvanzyl; state Exp;
+branches;
+next 1.80;
+
+1.80
+date 2002.12.31.07.01.38; author jvanzyl; state Exp;
+branches;
+next 1.79;
+
+1.79
+date 2002.12.18.17.13.37; author tcopeland; state Exp;
+branches;
+next 1.78;
+
+1.78
+date 2002.12.18.17.11.01; author tcopeland; state Exp;
+branches;
+next 1.77;
+
+1.77
+date 2002.12.12.11.37.11; author jvanzyl; state Exp;
+branches;
+next 1.76;
+
+1.76
+date 2002.12.11.22.30.07; author jvanzyl; state Exp;
+branches;
+next 1.75;
+
+1.75
+date 2002.12.10.23.03.04; author jvanzyl; state Exp;
+branches;
+next 1.74;
+
+1.74
+date 2002.12.10.15.46.51; author jvanzyl; state Exp;
+branches;
+next 1.73;
+
+1.73
+date 2002.12.03.02.48.36; author jvanzyl; state Exp;
+branches;
+next 1.72;
+
+1.72
+date 2002.12.02.15.21.44; author jvanzyl; state Exp;
+branches;
+next 1.71;
+
+1.71
+date 2002.12.01.23.26.10; author dion; state Exp;
+branches;
+next 1.70;
+
+1.70
+date 2002.11.30.17.18.25; author jvanzyl; state Exp;
+branches;
+next 1.69;
+
+1.69
+date 2002.11.24.23.41.12; author jvanzyl; state Exp;
+branches;
+next 1.68;
+
+1.68
+date 2002.11.24.19.19.37; author jvanzyl; state Exp;
+branches;
+next 1.67;
+
+1.67
+date 2002.11.24.19.12.45; author jvanzyl; state Exp;
+branches;
+next 1.66;
+
+1.66
+date 2002.11.24.19.00.37; author jvanzyl; state Exp;
+branches;
+next 1.65;
+
+1.65
+date 2002.11.24.18.45.59; author jvanzyl; state Exp;
+branches;
+next 1.64;
+
+1.64
+date 2002.11.24.17.58.59; author jvanzyl; state Exp;
+branches;
+next 1.63;
+
+1.63
+date 2002.11.15.22.14.01; author jvanzyl; state Exp;
+branches;
+next 1.62;
+
+1.62
+date 2002.11.15.19.47.25; author jvanzyl; state Exp;
+branches;
+next 1.61;
+
+1.61
+date 2002.11.14.06.39.37; author jvanzyl; state Exp;
+branches;
+next 1.60;
+
+1.60
+date 2002.11.14.06.33.52; author jvanzyl; state Exp;
+branches;
+next 1.59;
+
+1.59
+date 2002.11.14.04.12.32; author jvanzyl; state Exp;
+branches;
+next 1.58;
+
+1.58
+date 2002.11.14.03.25.23; author jvanzyl; state Exp;
+branches;
+next 1.57;
+
+1.57
+date 2002.11.13.17.47.37; author jvanzyl; state Exp;
+branches;
+next 1.56;
+
+1.56
+date 2002.11.12.16.41.00; author jvanzyl; state Exp;
+branches;
+next 1.55;
+
+1.55
+date 2002.11.12.04.04.36; author jvanzyl; state Exp;
+branches;
+next 1.54;
+
+1.54
+date 2002.11.05.15.37.37; author dion; state Exp;
+branches;
+next 1.53;
+
+1.53
+date 2002.11.04.14.59.37; author jtaylor; state Exp;
+branches;
+next 1.52;
+
+1.52
+date 2002.11.01.20.56.56; author smor; state Exp;
+branches;
+next 1.51;
+
+1.51
+date 2002.11.01.18.49.12; author evenisse; state Exp;
+branches;
+next 1.50;
+
+1.50
+date 2002.11.01.13.27.56; author smor; state Exp;
+branches;
+next 1.49;
+
+1.49
+date 2002.10.26.05.18.40; author dion; state Exp;
+branches;
+next 1.48;
+
+1.48
+date 2002.10.19.01.47.22; author jvanzyl; state Exp;
+branches;
+next 1.47;
+
+1.47
+date 2002.10.18.15.21.28; author jstrachan; state Exp;
+branches;
+next 1.46;
+
+1.46
+date 2002.10.14.07.39.23; author dion; state Exp;
+branches;
+next 1.45;
+
+1.45
+date 2002.08.25.12.38.08; author dion; state Exp;
+branches;
+next 1.44;
+
+1.44
+date 2002.08.25.12.35.44; author dion; state Exp;
+branches;
+next 1.43;
+
+1.43
+date 2002.08.23.03.17.20; author jvanzyl; state Exp;
+branches;
+next 1.42;
+
+1.42
+date 2002.08.22.19.40.43; author smor; state Exp;
+branches;
+next 1.41;
+
+1.41
+date 2002.08.18.17.46.19; author jvanzyl; state Exp;
+branches;
+next 1.40;
+
+1.40
+date 2002.08.15.20.28.37; author jvanzyl; state Exp;
+branches;
+next 1.39;
+
+1.39
+date 2002.08.15.18.13.25; author jvanzyl; state Exp;
+branches;
+next 1.38;
+
+1.38
+date 2002.08.15.17.42.37; author jvanzyl; state Exp;
+branches;
+next 1.37;
+
+1.37
+date 2002.07.27.23.11.45; author jvanzyl; state Exp;
+branches;
+next 1.36;
+
+1.36
+date 2002.07.26.19.50.21; author jvanzyl; state Exp;
+branches;
+next 1.35;
+
+1.35
+date 2002.07.26.18.16.13; author jvanzyl; state Exp;
+branches;
+next 1.34;
+
+1.34
+date 2002.07.25.17.54.10; author glennm; state Exp;
+branches;
+next 1.33;
+
+1.33
+date 2002.07.23.03.21.43; author jvanzyl; state Exp;
+branches;
+next 1.32;
+
+1.32
+date 2002.07.22.19.17.04; author jvanzyl; state Exp;
+branches;
+next 1.31;
+
+1.31
+date 2002.07.21.03.55.16; author jvanzyl; state Exp;
+branches;
+next 1.30;
+
+1.30
+date 2002.07.17.21.32.37; author jvanzyl; state Exp;
+branches;
+next 1.29;
+
+1.29
+date 2002.07.14.15.51.23; author dion; state Exp;
+branches;
+next 1.28;
+
+1.28
+date 2002.07.14.15.40.48; author dion; state Exp;
+branches;
+next 1.27;
+
+1.27
+date 2002.07.03.21.51.29; author jvanzyl; state Exp;
+branches;
+next 1.26;
+
+1.26
+date 2002.06.17.15.53.58; author dion; state Exp;
+branches;
+next 1.25;
+
+1.25
+date 2002.06.17.14.29.11; author dion; state Exp;
+branches;
+next 1.24;
+
+1.24
+date 2002.06.16.17.40.04; author dion; state Exp;
+branches;
+next 1.23;
+
+1.23
+date 2002.06.16.17.07.46; author dion; state Exp;
+branches;
+next 1.22;
+
+1.22
+date 2002.06.16.16.50.02; author dion; state Exp;
+branches;
+next 1.21;
+
+1.21
+date 2002.06.06.16.11.51; author dion; state Exp;
+branches;
+next 1.20;
+
+1.20
+date 2002.06.02.14.38.42; author vmassol; state Exp;
+branches;
+next 1.19;
+
+1.19
+date 2002.05.30.12.02.47; author jvanzyl; state Exp;
+branches;
+next 1.18;
+
+1.18
+date 2002.05.29.13.46.24; author jvanzyl; state Exp;
+branches;
+next 1.17;
+
+1.17
+date 2002.05.27.12.19.51; author dion; state Exp;
+branches;
+next 1.16;
+
+1.16
+date 2002.05.27.09.10.33; author dion; state Exp;
+branches;
+next 1.15;
+
+1.15
+date 2002.05.15.00.37.08; author dion; state Exp;
+branches;
+next 1.14;
+
+1.14
+date 2002.05.15.00.09.43; author dion; state Exp;
+branches;
+next 1.13;
+
+1.13
+date 2002.05.15.00.07.45; author dion; state Exp;
+branches;
+next 1.12;
+
+1.12
+date 2002.04.20.05.19.48; author kaz; state Exp;
+branches;
+next 1.11;
+
+1.11
+date 2002.04.19.14.50.09; author jvanzyl; state Exp;
+branches;
+next 1.10;
+
+1.10
+date 2002.04.16.21.15.19; author jvanzyl; state Exp;
+branches;
+next 1.9;
+
+1.9
+date 2002.04.06.16.05.27; author jvanzyl; state Exp;
+branches;
+next 1.8;
+
+1.8
+date 2002.04.05.00.10.33; author dlr; state Exp;
+branches;
+next 1.7;
+
+1.7
+date 2002.04.01.21.46.54; author jvanzyl; state Exp;
+branches;
+next 1.6;
+
+1.6
+date 2002.03.29.03.36.52; author jvanzyl; state Exp;
+branches;
+next 1.5;
+
+1.5
+date 2002.03.29.02.05.08; author jvanzyl; state Exp;
+branches;
+next 1.4;
+
+1.4
+date 2002.03.24.21.09.07; author jvanzyl; state Exp;
+branches;
+next 1.3;
+
+1.3
+date 2002.03.18.05.16.55; author brekke; state Exp;
+branches;
+next 1.2;
+
+1.2
+date 2002.03.05.04.12.57; author jvanzyl; state Exp;
+branches;
+next 1.1;
+
+1.1
+date 2002.02.28.22.41.02; author jvanzyl; state Exp;
+branches;
+next ;
+
+1.94.2.1
+date 2003.08.07.16.56.39; author dion; state Exp;
+branches;
+next 1.94.2.2;
+
+1.94.2.2
+date 2003.08.11.06.16.11; author dion; state Exp;
+branches;
+next 1.94.2.3;
+
+1.94.2.3
+date 2003.08.13.06.37.43; author dion; state Exp;
+branches;
+next 1.94.2.4;
+
+1.94.2.4
+date 2003.08.18.10.25.10; author brett; state Exp;
+branches;
+next ;
+
+1.107.2.1
+date 2003.10.30.11.46.30; author brett; state Exp;
+branches;
+next ;
+
+1.107.4.1
+date 2003.11.26.11.45.16; author brett; state Exp;
+branches;
+next 1.107.4.2;
+
+1.107.4.2
+date 2003.12.02.04.09.25; author brett; state Exp;
+branches;
+next 1.107.4.3;
+
+1.107.4.3
+date 2003.12.10.23.08.44; author brett; state Exp;
+branches;
+next 1.107.4.4;
+
+1.107.4.4
+date 2003.12.31.01.32.36; author brett; state Exp;
+branches;
+next 1.107.4.5;
+
+1.107.4.5
+date 2004.01.06.08.07.03; author brett; state Exp;
+branches;
+next 1.107.4.6;
+
+1.107.4.6
+date 2004.01.07.16.28.03; author dion; state Exp;
+branches;
+next 1.107.4.7;
+
+1.107.4.7
+date 2004.01.26.23.36.08; author brett; state Exp;
+branches;
+next 1.107.4.8;
+
+1.107.4.8
+date 2004.02.07.21.47.10; author brett; state Exp;
+branches;
+next 1.107.4.9;
+
+1.107.4.9
+date 2004.02.19.23.28.31; author brett; state Exp;
+branches;
+next 1.107.4.10;
+
+1.107.4.10
+date 2004.02.26.16.10.27; author brett; state Exp;
+branches;
+next 1.107.4.11;
+
+1.107.4.11
+date 2004.03.01.22.36.36; author evenisse; state Exp;
+branches;
+next 1.107.4.12;
+
+1.107.4.12
+date 2004.03.07.00.01.29; author brett; state Exp;
+branches;
+next 1.107.4.13;
+
+1.107.4.13
+date 2004.03.26.00.18.06; author brett; state Exp;
+branches;
+next 1.107.4.14;
+
+1.107.4.14
+date 2004.03.27.23.54.39; author brett; state Exp;
+branches;
+next 1.107.4.15;
+
+1.107.4.15
+date 2004.03.28.21.27.26; author evenisse; state Exp;
+branches;
+next 1.107.4.16;
+
+1.107.4.16
+date 2004.04.02.23.37.19; author brett; state Exp;
+branches;
+next 1.107.4.17;
+
+1.107.4.17
+date 2004.04.04.02.48.03; author brett; state Exp;
+branches;
+next 1.107.4.18;
+
+1.107.4.18
+date 2004.04.10.00.56.43; author brett; state Exp;
+branches;
+next 1.107.4.19;
+
+1.107.4.19
+date 2004.04.23.03.19.28; author brett; state Exp;
+branches;
+next 1.107.4.20;
+
+1.107.4.20
+date 2004.04.24.23.11.23; author brett; state Exp;
+branches;
+next 1.107.4.21;
+
+1.107.4.21
+date 2004.06.26.14.52.05; author dion; state Exp;
+branches;
+next 1.107.4.22;
+
+1.107.4.22
+date 2004.07.06.12.23.41; author brett; state Exp;
+branches;
+next ;
+
+
+desc
+@@
+
+
+1.111
+log
+@merge up to MAVEN_1_0_RC4
+@
+text
+@package org.apache.maven;
+
+/* ====================================================================
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * ====================================================================
+ */
+
+import com.werken.forehead.ForeheadClassLoader;
+
+import org.apache.commons.betwixt.XMLIntrospector;
+import org.apache.commons.betwixt.io.BeanReader;
+import org.apache.commons.betwixt.io.BeanWriter;
+import org.apache.commons.betwixt.strategy.DecapitalizeNameMapper;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.digester.ExtendedBaseRules;
+import org.apache.commons.digester.Rule;
+import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.expression.CompositeExpression;
+import org.apache.commons.jelly.expression.Expression;
+import org.apache.commons.jelly.expression.jexl.JexlExpressionFactory;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.maven.jelly.JellyUtils;
+import org.apache.maven.jelly.MavenJellyContext;
+import org.apache.maven.project.BaseObject;
+import org.apache.maven.project.Project;
+import org.apache.maven.util.StringInputStream;
+import org.apache.tools.ant.DirectoryScanner;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+import java.beans.IntrospectionException;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Utilities for reading maven project descriptors, profile descriptors and
+ * workspace descriptors.
+ *
+ * @@author <a href="mailto:jason@@zenplex.com">Jason van Zyl</a>
+ * @@author <a href="mailto:brett@@apache.org">Brett Porter</a>
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+ *
+ * @@todo Remove all the context creation code and make a ContextBuilder class.
+ * @@todo [RC2] split getProject (project.properties + defaults) != getPluginProject (plugin.properties only)
+ */
+public class MavenUtils
+{
+ /** Log. */
+ private static final Log log = LogFactory.getLog( MavenUtils.class );
+
+ /** we want to parse something */
+ private static final ThreadLocal xmlReaderPool = new ThreadLocal();
+
+ /** Should we cache and reuse the introspector */
+ private static boolean cacheIntrospector = true;
+
+ /** The singleton introspector if caching is enabled */
+ private static XMLIntrospector singletonIntrospector;
+
+ /** Project Bean Reader */
+ private static BeanReader projectBeanReader;
+
+ /** Map of loaded POMs. */
+ private static HashMap parentPoms = new HashMap();
+
+ /**
+ * Create a Project object given a file descriptor.
+ *
+ * @@param projectDescriptor a maven project.xml
+ * @@return the Maven project object for the given project descriptor
+ * @@throws MavenException when any errors occur
+ */
+ public static Project getProject( File projectDescriptor )
+ throws MavenException
+ {
+ return getProject( projectDescriptor, null );
+ }
+
+ /**
+ * Create a Project object given a file descriptor, and a parent context
+ * @@param projectDescriptor The file to create the project from
+ * @@param parentContext the parent Maven Jelly Context
+ * @@return a new Project
+ * @@throws MavenException when any error happens.
+ */
+ public static Project getProject( File projectDescriptor, MavenJellyContext parentContext )
+ throws MavenException
+ {
+ return getProject( projectDescriptor, parentContext, true );
+ }
+
+ /**
+ * Create a Project object given a file descriptor and optionally a parent Jelly
+ * context.
+ *
+ * @@param projectDescriptor a maven project.xml {@@link File}
+ * @@param parentContext the parent context for the new project
+ * @@param useParentPom whether a parent project should be respected
+ * @@return the MavenSession project object for the given project descriptor
+ * @@throws MavenException when any errors occur
+ */
+ public static Project getProject( File projectDescriptor,
+ MavenJellyContext parentContext,
+ boolean useParentPom )
+ throws MavenException
+ {
+ Project project = null;
+ try
+ {
+ project = getNonJellyProject( projectDescriptor, parentContext, useParentPom );
+ project = getJellyProject( project );
+ project.setFile( projectDescriptor );
+
+ // Fully initialize the project.
+ project.initialize();
+ }
+ catch (IntrospectionException e)
+ {
+ throw new MavenException("Error creating a string from the project", e);
+ }
+ catch (IOException e)
+ {
+ throw new MavenException("Error reading XML or initializing", e);
+ }
+ catch (ParserConfigurationException e)
+ {
+ throw new MavenException("Error creating a JAXP Parser", e);
+ }
+ catch (SAXException e)
+ {
+ throw new MavenException("Error parsing XML", e);
+ }
+
+ return project;
+ }
+
+ /**
+ * Get a project, but not a Jelly-ised project. ie Don't evaluate the
+ * variables. We are doing several things when creating a POM object, the phases
+ * are outlined here:
+ *
+ * 1) The project.xml file is read in using betwixt which creates for us a
+ * Project object that, at this point, has not been run through Jelly i.e.
+ * no interpolation has occured yet.
+ *
+ * 2) The context for the project is created and set. So each project manages its
+ * own context. See the createContext() method for the details context creation
+ * process.
+ *
+ * 3) We check to see if the <extend> tag is being employed. If so, the parent
+ * project.xml file is read in. At this point we have a child and parent POM
+ * and the values are merged where the child's values override those of the
+ * parent.
+ * @@param projectDescriptor the project file
+ * @@param parentContext the parent context for the new project
+ * @@param useParentPom whether a parent project should be respected
+ * @@return the project
+ * @@throws MavenException when there are errors reading the descriptor
+ * @@throws IOException when resolving file names and paths
+ */
+ private static Project getNonJellyProject( File projectDescriptor,
+ MavenJellyContext parentContext,
+ boolean useParentPom )
+ throws MavenException, IOException
+ {
+ // 1)
+ Project project = null;
+ try
+ {
+ project = (Project) getProjectBeanReader().parse( projectDescriptor );
+ }
+ catch (Exception e)
+ {
+ throw new MavenException("Error parsing project.xml '" + projectDescriptor.getAbsolutePath() + "'");
+ }
+
+ // 2)
+ MavenJellyContext context = MavenUtils.createContext( projectDescriptor.getParentFile(), parentContext );
+
+ // 3)
+ String pomToExtend = project.getExtend();
+
+ if ( pomToExtend != null && useParentPom )
+ {
+ // We must look in the <extend/> element for expressions that may be present as
+ //
+ // <extend>../project.xml</extend>
+ Expression e = JellyUtils.decomposeExpression( pomToExtend, context );
+ pomToExtend = e.evaluateAsString( context );
+ pomToExtend = MavenUtils.makeAbsolutePath( projectDescriptor.getParentFile(), pomToExtend );
+ project.setExtend( pomToExtend );
+
+ File parentPom = new File( pomToExtend );
+
+ Project parent = (Project) parentPoms.get( parentPom.getCanonicalPath() );
+ if ( parent == null )
+ {
+ parent = getNonJellyProject( parentPom, parentContext, true );
+ parent.setFile( parentPom );
+ parentPoms.put( parentPom.getCanonicalPath(), parent );
+
+ context.setParent( parent.getContext() );
+ }
+
+ Properties properties = loadProjectBuildProperties( parentPom.getParentFile() );
+ integrateMapInContext( properties, context );
+ properties = loadProjectProperties( parentPom.getParentFile() );
+ integrateMapInContext( properties, context );
+
+ project.mergeParent( parent );
+ }
+
+ // Set the created context, and put the project itself in the context. This
+ // is how we get the ${pom} reference in the project.xml file to work.
+ project.setContext( context );
+ context.setProject( project );
+
+ return project;
+ }
+
+ /**
+ * This is currently used for the reactor but may be generally useful.
+ *
+ * @@param directory the directory to scan for maven projects
+ * @@param includes the pattern that matches a project that you want included
+ * @@param excludes the pattern that matches a project that you don't want included
+ * @@return a {link List} of {@@link Project}s
+ * @@throws MavenException when anything goes wrong.
+ */
+ public static List getProjects( File directory, String includes, String excludes )
+ throws MavenException
+ {
+ return getProjects( directory, includes, excludes, null );
+ }
+
+ /**
+ * This is currently used for the reactor but may be generally useful.
+ *
+ * @@param directory the directory to scan for maven projects
+ * @@param includes Patterns to include.
+ * @@param excludes Patterns to exclude.
+ * @@param context the parent context
+ * @@return a {link List} of {@@link Project}s
+ * @@throws MavenException when anything goes wrong. FIXME this is bad
+ */
+ public static List getProjects( File directory,
+ String includes,
+ String excludes,
+ MavenJellyContext context )
+ throws MavenException
+ {
+ String[] files = getFiles( directory, includes, excludes );
+
+ List projects = new ArrayList();
+
+ for ( int i = 0; i < files.length; i++ )
+ {
+ Project p = getProject( new File( files[i] ), context );
+ projects.add( p );
+ }
+
+ return projects;
+ }
+
+ /**
+ * Create a project bean reader. We use it more than once so we don't want
+ * to create it more than once.
+ *
+ * @@return a {@@link BeanReader} capable of reading {@@link Project projects}
+ * @@throws IntrospectionException when creating a bean reader
+ * @@throws SAXException when an error occurs parsing the XML
+ * @@throws ParserConfigurationException when a JAXP parser can't be created
+ */
+ private static BeanReader getProjectBeanReader()
+ throws IntrospectionException, SAXException, ParserConfigurationException
+ {
+ if ( projectBeanReader == null )
+ {
+ projectBeanReader = createBeanReader( Project.class );
+ }
+
+ return projectBeanReader;
+ }
+
+ /**
+ * Take the POM and interpolate the value of the project's context to create
+ * a new version of the POM with expanded context values.
+ *
+ * @@param project the maven POM
+ * @@return Jelly interpolated project.
+ * @@throws IntrospectionException when there are errors creating a string from the project for interpolation
+ * @@throws SAXException when reading the interpolated POM fails
+ * @@throws IOException when there are errors reading
+ * @@throws ParserConfigurationException when a JAXP parser can't be created
+ */
+ private static Project getJellyProject( Project project )
+ throws IOException, SAXException, IntrospectionException, ParserConfigurationException
+ {
+ // Keep a copy of the original context
+ MavenJellyContext originalContext = project.getContext();
+
+ // We don't want any taglib references in the context or Jelly
+ // gets confused. All we want are the variables for interpolation. We
+ // can change this but I think we would like to avoid general Jelly
+ // idiom in the POM anyway.
+ JellyContext context = new JellyContext();
+ JellyUtils.populateVariables( context, originalContext );
+
+ // We don't want the context or the parent being written out into the XML which
+ // is the interpolated POM.
+ project.setContext( null );
+ Project parent = project.getParent();
+ project.setParent( null );
+
+ // Interpolate
+ project = getInterpolatedPOM(project, context);
+
+ // Restore parent and context
+ project.setParent( parent );
+ project.setContext( originalContext );
+ project.getContext().setProject( project );
+
+ return project;
+ }
+
+ /**
+ * Get the POM with all variables resolved.
+ * @@param project the project to resolve
+ * @@param context the context to retrieve variables from
+ * @@return a project with no unresolved elements.
+ * @@throws IOException if there is an error parsing the project
+ * @@throws SAXException if there is a sax error parsing the project
+ * @@throws IntrospectionException when there are errors creating a string from the project
+ * @@throws ParserConfigurationException when a JAXP parser can't be created
+ */
+ private static Project getInterpolatedPOM(Project project, JellyContext context)
+ throws IOException, SAXException, IntrospectionException, ParserConfigurationException
+ {
+ String projectString = getProjectString(project);
+ Expression e = JellyUtils.decomposeExpression( projectString, context );
+ String newProjectString = e.evaluateAsString( context );
+ project = (Project) getProjectBeanReader().parse( new StringReader( newProjectString ) );
+ return project;
+ }
+
+ /**
+ * @@return an {@@link InputStream} for the given project
+ * @@param project a {@@link Project maven project}
+ * @@throws MavenException when reading the project
+ */
+ public static InputStream getProjectInputStream( Project project )
+ throws MavenException
+ {
+ try
+ {
+ return new StringInputStream( getProjectString( project ) );
+ }
+ catch (IOException e)
+ {
+ throw new MavenException("Error writing the project", e);
+ }
+ catch (IntrospectionException e)
+ {
+ throw new MavenException("Error introspecting the project", e);
+ }
+ catch (SAXException e)
+ {
+ throw new MavenException("Error parsing the project as XML", e);
+ }
+ }
+
+ /**
+ * Create an XML string from a project.
+ *
+ * @@param project MavenSession project to turn into an XML representation.
+ * @@return XML representation of the project
+ * @@throws IOException writing the project fails
+ * @@throws IntrospectionException when there are problems writing the project bean as a string
+ * @@throws SAXException when there are problems writing the project bean as a string
+ */
+ private static String getProjectString( Project project ) throws IOException, IntrospectionException, SAXException
+ {
+ ByteArrayOutputStream projectStream = new ByteArrayOutputStream();
+ BeanWriter beanWriter = new BeanWriter( projectStream );
+ beanWriter.setXMLIntrospector( createXMLIntrospector() );
+
+ beanWriter.setWriteIDs( true );
+ beanWriter.write( project );
+
+ return projectStream.toString( System.getProperty( "file.encoding" ) );
+ }
+
+ /**
+ * Get a set of files from a specifed directory with a set of includes.
+ *
+ * @@param directory Directory to scan.
+ * @@param includes Comma separated list of includes.
+ * @@return files
+ */
+ public static String[] getFiles( File directory, String includes )
+ {
+ return getFiles( directory, includes, null );
+ }
+
+ /**
+ * Get a set of files from a specifed directory with a set of includes.
+ *
+ * @@param directory Directory to scan.
+ * @@param includes Comma separated list of includes.
+ * @@param excludes Comma separated list of excludes.
+ * @@return files
+ */
+ public static String[] getFiles( File directory, String includes, String excludes )
+ {
+ String[] includePatterns = null;
+ if ( includes != null )
+ {
+ includePatterns = StringUtils.split( includes, "," );
+ }
+
+ String[] excludePatterns = null;
+ if ( excludes != null )
+ {
+ excludePatterns = StringUtils.split( excludes, "," );
+ }
+
+ DirectoryScanner directoryScanner = new DirectoryScanner();
+ directoryScanner.setBasedir( directory );
+ directoryScanner.setIncludes( includePatterns );
+ directoryScanner.setExcludes( excludePatterns );
+ directoryScanner.scan();
+ String[] files = directoryScanner.getIncludedFiles();
+
+ for ( int i = 0; i < files.length; i++ )
+ {
+ files[i] = new File( directory, files[i] ).getAbsolutePath();
+ }
+
+ return files;
+ }
+
+
+ /**
+ * Creates a new instance of BeanReader
+ *
+ * @@param clazz the class to register with the reader
+ * @@return a {@@link BeanReader bean reader}
+ * @@throws IntrospectionException when there are errors registering the provided class
+ * @@throws SAXException when there are errors getting an XML reader
+ * @@throws ParserConfigurationException when there are errors getting an XML reader
+ */
+ public static BeanReader createBeanReader( Class clazz )
+ throws IntrospectionException, SAXException, ParserConfigurationException
+ {
+ BeanReader beanReader = new BeanReader( getXMLReader() );
+ beanReader.setRules( new ExtendedBaseRules() );
+ beanReader.addRule( "*/properties/?", new MetaPropertiesRule() );
+
+ beanReader.setXMLIntrospector( getXMLIntrospector() );
+ beanReader.registerBeanClass( clazz );
+
+ return beanReader;
+ }
+
+ /**
+ * If caching is enabled then this method will return a pooled introspector
+ *
+ * @@return XMLIntrospector used for processing the MavenSession xml-based POM.
+ */
+ public static XMLIntrospector getXMLIntrospector()
+ {
+ if ( cacheIntrospector )
+ {
+ if ( singletonIntrospector == null )
+ {
+ singletonIntrospector = createXMLIntrospector();
+ }
+ return singletonIntrospector;
+ }
+ return createXMLIntrospector();
+ }
+
+ /**
+ * Create the type of XMLIntrospector that is used to read all MavenSession style
+ * XML files.
+ *
+ * @@return Betwixt XMLIntrospector
+ */
+ private static XMLIntrospector createXMLIntrospector()
+ {
+ XMLIntrospector introspector = new XMLIntrospector();
+
+ introspector.setAttributesForPrimitives( false );
+ introspector.setElementNameMapper( new DecapitalizeNameMapper() );
+
+ return introspector;
+ }
+
+ /**
+ * Get the XMLReader to use for processing XML related resources.
+ *
+ * @@return an XMLReader which is pooled per thread
+ * @@throws SAXException when the reader can't be created
+ * @@throws ParserConfigurationException when the reader can't be created
+ */
+ public static XMLReader getXMLReader() throws SAXException, ParserConfigurationException
+ {
+ XMLReader parser = (XMLReader) xmlReaderPool.get();
+ if ( parser == null )
+ {
+ parser = createXMLReader();
+ xmlReaderPool.set( parser );
+ }
+ return parser;
+ }
+
+ /**
+ * Creates a new XMLReader instance
+ *
+ * @@return XMLReader used for parsing XML related maven resource.
+ * @@throws SAXException If there are errors creating the reader
+ * @@throws ParserConfigurationException If there are errors creating the SAX parser to use
+ */
+ private static XMLReader createXMLReader() throws SAXException, ParserConfigurationException
+ {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+
+ factory.setNamespaceAware( true );
+
+ return factory.newSAXParser().getXMLReader();
+ }
+
+ /**
+ * Take a dominant and recessive Map and merge the key:value
+ * pairs where the recessive Map may add key:value pairs to the dominant
+ * Map but may not override any existing key:value pairs.
+ *
+ * If we have two Maps, a dominant and recessive, and
+ * their respective keys are as follows:
+ *
+ * dominantMapKeys = { a, b, c, d, e, f }
+ * recessiveMapKeys = { a, b, c, x, y, z }
+ *
+ * Then the result should be the following:
+ *
+ * resultantKeys = { a, b, c, d, e, f, x, y, z }
+ *
+ * @@param dominantMap Dominant Map.
+ * @@param recessiveMap Recessive Map.
+ * @@return The result map with combined dominant and recessive values.
+ */
+ public static Map mergeMaps( Map dominantMap, Map recessiveMap )
+ {
+ Map result = new HashMap();
+
+ if ( dominantMap == null && recessiveMap == null )
+ {
+ return null;
+ }
+
+ if ( dominantMap != null && recessiveMap == null )
+ {
+ return dominantMap;
+ }
+
+ if ( dominantMap == null )
+ {
+ return recessiveMap;
+ }
+
+ // Grab the keys from the dominant and recessive maps.
+ Set dominantMapKeys = dominantMap.keySet();
+ Set recessiveMapKeys = recessiveMap.keySet();
+
+ // Create the set of keys that will be contributed by the
+ // recessive Map by subtracting the intersection of keys
+ // from the recessive Map's keys.
+ Collection contributingRecessiveKeys =
+ CollectionUtils.subtract( recessiveMapKeys,
+ CollectionUtils.intersection( dominantMapKeys, recessiveMapKeys ) );
+
+ result.putAll( dominantMap );
+
+ // Now take the keys we just found and extract the values from
+ // the recessiveMap and put the key:value pairs into the dominantMap.
+ for ( Iterator i = contributingRecessiveKeys.iterator(); i.hasNext();)
+ {
+ Object key = i.next();
+ result.put( key, recessiveMap.get( key ) );
+ }
+
+ return result;
+ }
+
+ /**
+ * Take a series of <code>Map</code>s and merge
+ * them where the ordering of the array from 0..n
+ * is the dominant order.
+ *
+ * @@param maps An array of Maps to merge.
+ * @@return Map The result Map produced after the merging process.
+ */
+ public static Map mergeMaps( Map[] maps )
+ {
+ Map result;
+
+ if ( maps.length == 0 )
+ {
+ result = null;
+ }
+ else if ( maps.length == 1 )
+ {
+ result = maps[0];
+ }
+ else
+ {
+ result = mergeMaps( maps[0], maps[1] );
+
+ for ( int i = 2; i < maps.length; i++ )
+ {
+ result = mergeMaps( result, maps[i] );
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Load the build.properties file for a project.
+ * @@param directory the directory of the project
+ * @@return the properties
+ */
+ private static Properties loadProjectBuildProperties( File directory )
+ {
+ // project build properties
+ File projectBuildPropertiesFile =
+ new File( directory, "build.properties" );
+
+ log.debug( "Using projectBuildPropertiesFile: " + projectBuildPropertiesFile.getAbsolutePath() );
+ return loadProperties( projectBuildPropertiesFile );
+ }
+
+ /**
+ * Load the project.properties file for a project.
+ * @@param directory the directory of the project
+ * @@return the properties
+ */
+ private static Properties loadProjectProperties( File directory )
+ {
+ // project properties
+ File projectPropertiesFile =
+ new File( directory, "project.properties" );
+
+ log.debug( "Using projectPropertiesFile: " + projectPropertiesFile.getAbsolutePath() );
+ return loadProperties( projectPropertiesFile );
+ }
+
+ /**
+ * Create a jelly context given a descriptor directory.
+ *
+ * @@param descriptorDirectory The directory from which to pull the standard maven
+ * properties files from.
+ * @@return The generated maven based on the contents of the standard maven
+ * properties files.
+ */
+ public static MavenJellyContext createContext( File descriptorDirectory )
+ {
+ return createContext( descriptorDirectory, null );
+ }
+
+ /**
+ * Create a jelly context given a descriptor directory and parent
+ * jelly context.
+ *
+ * @@param descriptorDirectory The directory from which to pull the standard maven
+ * properties files from.
+ * @@param parentContext The parent jelly context.
+ * @@todo should premerge driver, etc if they are being kept
+ * @@return The generated maven based on the contents of the standard maven
+ * properties files.
+ */
+ public static MavenJellyContext createContext( File descriptorDirectory,
+ MavenJellyContext parentContext )
+ {
+ // System properties
+ Properties systemProperties = System.getProperties();
+
+ // User build properties
+ File userBuildPropertiesFile =
+ new File( System.getProperty( "user.home" ), "build.properties" );
+
+ log.debug( "Using userBuildPropertiesFile: " + userBuildPropertiesFile.getAbsolutePath() );
+ Properties userBuildProperties = loadProperties( userBuildPropertiesFile );
+
+ Properties projectProperties = loadProjectProperties( descriptorDirectory );
+ Properties projectBuildProperties = loadProjectBuildProperties( descriptorDirectory );
+
+ Properties driverProperties = loadProperties(
+ MavenUtils.class.getResourceAsStream(
+ MavenConstants.DRIVER_PROPERTIES ) );
+
+ Properties defaultProperties = loadProperties(
+ MavenUtils.class.getResourceAsStream(
+ MavenConstants.DEFAULTS_PROPERTIES ) );
+
+ Map result = MavenUtils.mergeMaps( new Map[]
+ {
+ systemProperties,
+ userBuildProperties,
+ projectBuildProperties,
+ projectProperties,
+ driverProperties
+ } );
+
+ MavenJellyContext context;
+
+ // If we have a parent we eventually want what values it can provide but
+ // we turn inheritance off momentarily until we finish integrating the
+ // child's context values into the jelly context because we want the
+ // child values to win and only use the parent in the event the
+ // child cannot provide the value.
+
+ if ( parentContext != null )
+ {
+ context = new MavenJellyContext( parentContext );
+ context.setInherit( false );
+
+ MavenUtils.integrateMapInContext( result, context );
+
+ // Turn inheritance back on to make the parent's values visible.
+ context.setInherit( true );
+
+ //add in the default.properties with defaults, but in inheritance mode.
+ MavenUtils.integrateMapInContext( defaultProperties, context );
+ }
+ else
+ {
+ context = new MavenJellyContext();
+
+ //integrate everything else...
+ MavenUtils.integrateMapInContext( result, context );
+
+ //integrate defaults...
+ MavenUtils.integrateMapInContext( defaultProperties, context );
+
+ // Turn inheritance back on to make the parent's values visible.
+ context.setInherit( true );
+ }
+
+
+ // Set the basedir value in the context.
+ context.setVariable( "basedir", descriptorDirectory.getAbsolutePath() );
+
+ // deliberately use the original base directory for these variables
+ context.resolveRelativePaths( new File( System.getProperty( "user.dir" ) ) );
+
+ return context;
+ }
+
+ /**
+ * Integrate a Map of key:value pairs into a <code>MavenJellyContext</code>.
+ * The values in the Map may be <code>CompositeExpression</code>s that need
+ * to be evaluated before being placed into the context.
+ *
+ * @@param map Map to integrate into the provided jelly context.
+ * @@param context Jelly context to integrate the map into.
+ */
+ public static void integrateMapInContext( Map map, MavenJellyContext context )
+ {
+ if ( map == null )
+ {
+ return;
+ }
+
+ JexlExpressionFactory factory = new JexlExpressionFactory();
+
+ for ( Iterator i = map.keySet().iterator(); i.hasNext();)
+ {
+ String key = (String) i.next();
+ Object value;
+
+ if ( context.getVariable( key ) == null )
+ {
+ value = map.get( key );
+
+ try
+ {
+ String literalValue = (String) value;
+ Expression expr = CompositeExpression.parse( literalValue, factory );
+
+ if ( expr != null )
+ {
+ value = expr;
+ }
+ else
+ {
+ value = literalValue;
+ }
+ }
+ catch ( Exception e )
+ {
+ // do nothing.
+ log.debug( "Unexpected error evaluating expression", e );
+ }
+ context.setVariable( key, value );
+ }
+ }
+ }
+
+ /**
+ * Load properties from a <code>File</code>.
+ *
+ * @@param file Propertie file to load.
+ * @@return The loaded Properties.
+ */
+ private static Properties loadProperties( File file )
+ {
+ try
+ {
+ if ( file.exists() )
+ {
+ return loadProperties( new FileInputStream (file) );
+ }
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ log.debug("Unexpected error loading properties", e);
+ }
+
+ return null;
+ }
+
+ /**
+ * Load properties from an <code>InputStream</code>.
+ *
+ * @@param is InputStream from which load properties.
+ * @@return The loaded Properties.
+ */
+ private static Properties loadProperties( InputStream is )
+ {
+ try
+ {
+ Properties properties = new Properties();
+ properties.load( is );
+
+ for ( Iterator i = properties.keySet().iterator(); i.hasNext(); )
+ {
+ String property = ( String ) i.next();
+ properties.setProperty( property, properties.getProperty( property ).trim() );
+ }
+
+ return properties;
+ }
+ catch ( IOException e )
+ {
+ // ignore
+ log.debug("Unexpected exception loading properties", e);
+ }
+ finally
+ {
+ try
+ {
+ if ( is != null )
+ {
+ is.close();
+ }
+ }
+ catch ( IOException e )
+ {
+ // ignore
+ log.debug("Unexpected exception loading properties", e);
+ }
+ }
+
+ return null;
+ }
+
+ // ------------------------------------------------------------
+ // M E T A P R O P E R T I E S R U L E C L A S S
+ // ------------------------------------------------------------
+
+ /**
+ * A simple digester rule for populating an object in the POM
+ * with meta properties.
+ */
+ static class MetaPropertiesRule
+ extends Rule
+ {
+ /** The body of the found property. */
+ private String value;
+
+ /**
+ * Constructor for the InfoRule object
+ */
+ public MetaPropertiesRule()
+ {
+ }
+
+ /**
+ * Process the body of this element.
+ *
+ * @@param namespace the namespace
+ * @@param name the tag name
+ * @@param text the body text
+ */
+ public void body(String namespace, String name, String text)
+ {
+ this.value = text;
+ }
+
+ /**
+ * Finish off this element.
+ * @@param namespace the namespace of the element
+ * @@param elementName the name of the element
+ */
+ public void end(String namespace, String elementName)
+ {
+ BaseObject baseObject = (BaseObject) getDigester().peek();
+ String name = getDigester().getCurrentElementName();
+ baseObject.addProperty( name + ":" + value );
+ }
+ }
+
+ /** Resource bundle with user messages. */
+ private static ResourceBundle messages;
+
+ /**
+ * Load MavenSession user messages from a resource bundle given the
+ * user's locale.
+ * @@todo Move locale tools into their own class.
+ */
+ private static void loadMessages()
+ {
+ try
+ {
+ // Look for the message bundle corresponding to the user's locale.
+ messages = ResourceBundle.getBundle( "org/apache/maven/messages/messages" );
+ }
+ catch ( MissingResourceException e )
+ {
+ // If we can't find the appropriate message bundle for the locale then
+ // we will fall back to English.
+ messages = ResourceBundle.getBundle( "org/apache/maven/messages/messages",
+ Locale.ENGLISH );
+ }
+ }
+
+ /**
+ * Retrieve a user message.
+ *
+ * @@param messageId Id of message type to use.
+ * @@return Message for the user's locale.
+ */
+ public static String getMessage( String messageId )
+ {
+ return getMessage( messageId, null );
+ }
+
+ /**
+ * Retrieve a user message.
+ *
+ * @@param messageId Id of message type to use.
+ * @@param variable Value to substitute for ${1} in the given message.
+ * @@return Message for the user's locale.
+ */
+ public static String getMessage( String messageId, Object variable )
+ {
+ if ( messages == null )
+ {
+ loadMessages();
+ }
+
+ if ( variable == null )
+ {
+ return messages.getString( messageId );
+ }
+ else
+ {
+ return StringUtils.replace( messages.getString( messageId ),
+ "${1}",
+ variable.toString() );
+ }
+ }
+
+ /**
+ * Resolve directory against a base directory if it is not already absolute.
+ * @@param basedir the base directory for relative paths
+ * @@param dir the directory to resolve
+ * @@throws IOException if canonical path fails
+ * @@return the canonical path of the directory if not absolute
+ */
+ public static String makeAbsolutePath( File basedir, String dir ) throws IOException
+ {
+ File f = new File( dir );
+ if ( !(f.isAbsolute()) )
+ {
+ return new File( basedir, dir ).getCanonicalPath();
+ }
+ else
+ {
+ return f.getCanonicalPath();
+ }
+ }
+
+ /**
+ * Convert an absolute path to a relative path if it is under a given base directory.
+ * @@param basedir the base directory for relative paths
+ * @@param path the directory to resolve
+ * @@return the relative path
+ * @@throws IOException if canonical path fails
+ */
+ public static String makeRelativePath( File basedir, String path ) throws IOException
+ {
+ String canonicalBasedir = basedir.getCanonicalPath();
+ String canonicalPath = new File( path ).getCanonicalPath();
+
+ if ( canonicalPath.equals(canonicalBasedir) )
+ {
+ return ".";
+ }
+
+ if ( canonicalPath.startsWith( canonicalBasedir ) )
+ {
+ if ( canonicalPath.charAt( canonicalBasedir.length() ) == File.separatorChar )
+ {
+ canonicalPath = canonicalPath.substring( canonicalBasedir.length() + 1 );
+ }
+ else
+ {
+ canonicalPath = canonicalPath.substring( canonicalBasedir.length() );
+ }
+ }
+ return canonicalPath;
+ }
+
+ /**
+ * Get a list of goals from a CSV list.
+ * @@param goalCsv the goals
+ * @@return the list of goal names
+ */
+ public static List getGoalListFromCsv( String goalCsv )
+ {
+ StringTokenizer tok = new StringTokenizer( goalCsv, "," );
+ List goals = new ArrayList();
+ while ( tok.hasMoreTokens() )
+ {
+ goals.add( tok.nextToken() );
+ }
+ return goals;
+ }
+
+ /**
+ * Debugging function.
+ * @@param classLoader the class loader
+ */
+ public static void displayClassLoaderContents( ForeheadClassLoader classLoader )
+ {
+ System.out.println( "ClassLoader name: " + classLoader.getName() );
+
+ URL[] urls = classLoader.getURLs();
+
+ for ( int i = 0; i < urls.length; i++ )
+ {
+ System.out.println( "urls[" + i + "] = " + urls[i] );
+ }
+
+ ClassLoader parent = classLoader.getParent();
+ if ( parent != null && parent instanceof ForeheadClassLoader )
+ {
+ System.out.println( "Displaying Parent classloader: " );
+ displayClassLoaderContents( ( ForeheadClassLoader ) classLoader.getParent());
+ }
+ }
+
+}
+@
+
+
+1.110
+log
+@merge changes between MAVEN_1_0_RC2 and MAVEN-1_0-BRANCH-merge-3
+@
+text
+@d21 1
+d75 1
+a75 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+@
+
+
+1.109
+log
+@merge changes on MAVEN-1_0-BRANCH between MAVEN-1_0-BRANCH-merge-2 and MAVEN-1_0-RC2
+@
+text
+@a35 1
+import org.apache.maven.jelly.MavenExpressionFactory;
+d44 1
+d46 2
+d74 1
+a74 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+a83 3
+ /** Internal encoding used for Jelly interpolation. */
+ private static final String INTERNAL_ENCODING = "ISO-8859-1";
+
+a95 3
+ /** Maven Expression Factory. */
+ private static MavenExpressionFactory mavenExpressionFactory = new MavenExpressionFactory();
+
+d104 1
+a104 1
+ * @@throws Exception when any errors occur
+d107 1
+a107 1
+ throws Exception
+d117 1
+a117 1
+ * @@throws Exception when any error happens. FIXME
+d120 1
+a120 1
+ throws Exception
+d133 1
+a133 1
+ * @@throws Exception when any errors occur - TODO [RC2] bad
+d138 1
+a138 1
+ throws Exception
+d140 6
+a145 3
+ Project project = getNonJellyProject( projectDescriptor, parentContext, useParentPom );
+ project = getJellyProject( project );
+ project.setFile( projectDescriptor );
+d147 19
+a165 2
+ // Fully initialize the project.
+ project.initialize();
+d191 2
+a192 1
+ * @@throws Exception when any errors occur - TODO [RC2] bad
+d197 1
+a197 1
+ throws Exception
+d200 9
+a208 1
+ Project project = (Project) getProjectBeanReader().parse( projectDescriptor );
+d221 1
+a221 1
+ Expression e = JellyUtils.decomposeExpression( pomToExtend, mavenExpressionFactory, context );
+d261 1
+a261 1
+ * @@throws Exception when anything goes wrong. FIXME this is bad
+d264 1
+a264 1
+ throws Exception
+d277 1
+a277 1
+ * @@throws Exception when anything goes wrong. FIXME this is bad
+d283 1
+a283 1
+ throws Exception
+d303 3
+a305 1
+ * @@throws Exception when anything goes wrong. FIXME this is bad
+d308 1
+a308 1
+ throws Exception
+d324 4
+a327 1
+ * @@throws Exception when anything goes wrong. FIXME this is bad
+d330 1
+a330 1
+ throws Exception
+d340 1
+a340 1
+ context.setVariables( originalContext.getVariables() );
+a363 1
+ * @@throws Exception when there is an error getting the project as a string
+d366 2
+d370 1
+a370 1
+ throws Exception, IOException, SAXException
+d373 1
+a373 1
+ Expression e = JellyUtils.decomposeExpression( projectString, mavenExpressionFactory, context );
+d382 1
+a382 1
+ * @@throws Exception when anything goes wrong. FIXME this is bad
+d385 1
+a385 1
+ throws Exception
+d387 16
+a402 1
+ return new StringInputStream( getProjectString( project ) );
+d410 3
+a412 1
+ * @@throws Exception when anything goes wrong. FIXME this is bad
+d414 1
+a414 2
+ public static String getProjectString( Project project )
+ throws Exception
+d423 1
+a423 4
+ // We do not care what the original encoding was originally. This
+ // is all completely internal. Our StringInputStream requires
+ // everything to be encoded in "ISO-8859-1".
+ return projectStream.toString( INTERNAL_ENCODING );
+d481 3
+a483 3
+ * @@throws Exception when an error occurs trying to determine
+ * properties of the class provided
+ * @@throws Exception when anything goes wrong. FIXME this is bad
+d486 1
+a486 1
+ throws Exception
+d536 2
+a537 1
+ * @@throws Exception If an error occurs while creating the XMLReader.
+d539 1
+a539 2
+ public static XMLReader getXMLReader()
+ throws Exception
+d554 2
+a555 1
+ * @@throws Exception If an error occurs while creating the reader.
+d557 1
+a557 2
+ private static XMLReader createXMLReader()
+ throws Exception
+d715 1
+a715 1
+ public static MavenJellyContext createContext( File descriptorDirectory,
+d787 3
+d817 1
+a817 1
+ String literalValue = (String) map.get( key );
+d821 1
+a831 2
+
+ context.setVariable( key, value );
+d836 1
+a836 1
+ log.debug("Unexpected error evaluating expression", e);
+d838 1
+d879 7
+a938 1
+ * @@throws Exception when any errors occur
+a940 1
+ throws Exception
+a948 1
+ * @@throws Exception when any errors occur
+a950 1
+ throws Exception
+d1088 1
+a1088 2
+ * @@param project
+ * @@param classLoader
+@
+
+
+1.108
+log
+@merge in 1.0 branch
+@
+text
+@d4 1
+a4 1
+ * The Apache Software License, Version 1.1
+d6 3
+a8 2
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
+ * reserved.
+d10 1
+a10 46
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Maven" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache Maven", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * 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/>.
+d12 5
+d72 1
+a72 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+d206 1
+a206 1
+ parent = getNonJellyProject( parentPom, null, true );
+d806 4
+a809 1
+ return loadProperties( new FileInputStream (file) );
+d1043 2
+@
+
+
+1.107
+log
+@style
+@
+text
+@d59 1
+a63 1
+import org.apache.commons.collections.BeanMap;
+d91 1
+d103 1
+d110 2
+a111 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+d114 1
+d119 1
+a119 1
+ private static final Log logger = LogFactory.getLog( MavenUtils.class );
+d170 26
+a195 1
+ * context. We are doing several things when creating a POM object, the phases
+d206 1
+a206 1
+ * 3) We check to see if the <extend> tag is being employed. If so, the parent
+d210 1
+a210 7
+ *
+ * 4) The POM we have at this point is then processed through Jelly.
+ *
+ * 5) The project is handed the reference to the File that was used to create
+ * the project itself.
+ *
+ * @@param projectDescriptor a maven project.xml {@@link File}
+d213 2
+a214 2
+ * @@return the MavenSession project object for the given project descriptor
+ * @@throws Exception when any errors occur
+d216 3
+a218 3
+ public static Project getProject( File projectDescriptor,
+ MavenJellyContext parentContext,
+ boolean useParentPom )
+a220 2
+ //if ( pom.get())
+
+d225 2
+a226 2
+ MavenJellyContext context = MavenUtils.createContext( projectDescriptor.getParentFile(),
+ parentContext );
+d245 3
+a247 1
+ parent = (Project) getProjectBeanReader().parse( parentPom );
+d249 1
+a249 4
+ if ( parent != null )
+ {
+ parentPoms.put( parentPom.getCanonicalPath(), parent );
+ }
+d252 4
+a255 2
+ // This is very slow. A BCEL solution would be very nice here.
+ project = (Project) mergeBeans( project, parent );
+d257 1
+a257 3
+ // Now let's do some magic with dependencies. We take all
+ // the parent's dependencies and put them in with the childs.
+ project.addParentDependencies( parent.getDependencies() );
+a264 9
+ // 4)
+ project = getJellyProject( project );
+
+ // 5)
+ project.setFile( projectDescriptor );
+
+ // Fully initialize the project.
+ project.initialize();
+
+d272 2
+a273 2
+ * @@param includes the pattern that matches a project
+ * @@param context the parent context
+d277 1
+a277 1
+ public static List getProjects( File directory, String includes, MavenJellyContext context )
+d280 1
+a280 1
+ return getProjects( directory, includes, null, context );
+d341 1
+a341 2
+ // Save the original context because we null it temporarly
+ // while we funnel it through betwixt.
+d351 1
+a351 1
+ // We don't want the context being written out into the XML which
+d354 4
+d360 2
+a384 16
+// Script script = JellyUtils.compileScript( getProjectInputStream(project),
+// context,
+// INTERNAL_ENCODING );
+//
+// // Now run the script against the fully populated context so all the
+// // values are filled in correctly.
+// ByteArrayOutputStream baos = new ByteArrayOutputStream();
+// Writer writer = new BufferedWriter( new OutputStreamWriter( baos, INTERNAL_ENCODING ) );
+// XMLOutput output = XMLOutput.createXMLOutput( writer );
+// script.run( context, output );
+// writer.close();
+//
+// // Read in the the project.xml contents with the interpolated values and
+// // put back the original context with all the values that have been populated
+// // but change the project in the context to the newly interpolated version.
+// project = (Project) getProjectBeanReader().parse( new StringReader( baos.toString() ) );
+a421 80
+ * Merge a child and parent Project object.
+ *
+ * @@param child child object
+ * @@param parent the maven project
+ * @@return the child after properties from the parent are merged
+ */
+ private static Object mergeBeans( Object child, Object parent )
+ {
+ BeanMap parentBeanMap = new BeanMap( parent );
+ BeanMap childBeanMap = new BeanMap( child );
+
+ for ( Iterator i = parentBeanMap.keySet().iterator(); i.hasNext();)
+ {
+ // Take the property for the parent and insert it
+ // into the child bean map.
+ String property = (String) i.next();
+
+ try
+ {
+ // If the childs property is null then take it from
+ // the parent.
+ Object c = childBeanMap.get( property );
+ Object p = parentBeanMap.get( property );
+
+ if ( valueNeedsPopulating( c ) )
+ {
+ childBeanMap.put( property, p );
+ }
+ else if ( c != null && p != null && !valuePrimitive( c ) )
+ {
+ Object mergedBean = mergeBeans( c, p );
+ childBeanMap.put( property, mergedBean );
+ }
+ }
+ catch ( IllegalArgumentException e )
+ {
+ // There is no write method for this property.
+ logger.debug("No write method for property", e);
+ }
+ }
+ return child;
+ }
+
+ /**
+ * Test if a value is a primitive or not
+ *
+ * @@param o the value to test
+ * @@return true if o is a Boolean, String, Class or Integer.
+ */
+ private static boolean valuePrimitive( Object o )
+ {
+ if ( o instanceof Boolean || o instanceof String
+ || o instanceof Class || o instanceof Integer )
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check a child value to see if it needs populating with the parent value.
+ * The constructor sets List values to [] so we have to check those.
+ *
+ * @@param o a child value
+ * @@return true if the child value is an empty collection or null
+ */
+ private static boolean valueNeedsPopulating( Object o )
+ {
+ if ( o instanceof Collection && ( (Collection) o ).size() == 0 )
+ {
+ return true;
+ }
+ else
+ {
+ // it needs populating if it's null
+ return (o == null);
+ }
+ }
+
+ /**
+d594 1
+a594 1
+ if ( dominantMap == null && recessiveMap != null )
+d633 1
+a633 1
+ Map result = null;
+d657 30
+d706 1
+d720 1
+a720 1
+ logger.debug( "Using userBuildPropertiesFile: " + userBuildPropertiesFile.getAbsolutePath() );
+d723 2
+a724 13
+ // project build properties
+ File projectBuildPropertiesFile =
+ new File( descriptorDirectory, "build.properties" );
+
+ logger.debug( "Using projectBuildPropertiesFile: " + projectBuildPropertiesFile.getAbsolutePath() );
+ Properties projectBuildProperties = loadProperties( projectBuildPropertiesFile );
+
+ // project properties
+ File projectPropertiesFile =
+ new File( descriptorDirectory, "project.properties" );
+
+ logger.debug( "Using projectPropertiesFile: " + projectPropertiesFile.getAbsolutePath() );
+ Properties projectProperties = loadProperties( projectPropertiesFile );
+d727 1
+a727 1
+ MavenUtils.class.getClassLoader().getResourceAsStream(
+d731 1
+a731 1
+ MavenUtils.class.getClassLoader().getResourceAsStream(
+d761 1
+a761 1
+ //add in the driver.properties with defaults, but in inheritance mode.
+d780 1
+a780 1
+ context.setVariable( "basedir", descriptorDirectory.getPath() );
+d829 1
+a829 1
+ logger.debug("Unexpected error evaluating expression", e);
+d850 1
+a850 1
+ logger.debug("Unexpected error loading properties", e);
+d873 1
+a873 1
+ logger.debug("Unexpected exception loading properties", e);
+d887 1
+a887 1
+ logger.debug("Unexpected exception loading properties", e);
+d1055 39
+@
+
+
+1.107.4.1
+log
+@migrate "unstable" branch
+@
+text
+@a58 21
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.xml.parsers.SAXParserFactory;
+
+d63 1
+d84 19
+d108 1
+a108 2
+ * @@author <a href="mailto:brett@@apache.org">Brett Porter</a>
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+a110 1
+ * @@todo [RC2] split getProject (project.properties + defaults) != getPluginProject (plugin.properties only)
+d184 3
+a186 1
+ * @@todo should cache all project xml files with the right context , merged down to the leafs in inheritence
+a205 1
+
+d225 5
+a229 2
+ parent.setFile( parentPom );
+ parentPoms.put( parentPom.getCanonicalPath(), parent );
+d232 2
+a233 4
+ Properties properties = loadProjectBuildProperties( parentPom.getParentFile() );
+ integrateMapInContext( properties, context );
+ properties = loadProjectProperties( parentPom.getParentFile() );
+ integrateMapInContext( properties, context );
+d235 3
+a237 1
+ project.mergeParent( parent );
+d247 2
+d261 2
+a262 2
+ * @@param includes the pattern that matches a project that you want included
+ * @@param excludes the pattern that matches a project that you don't want included
+d266 1
+a266 1
+ public static List getProjects( File directory, String includes, String excludes )
+d269 1
+a269 1
+ return getProjects( directory, includes, excludes, null );
+d341 1
+a341 1
+ // We don't want the context or the parent being written out into the XML which
+a343 4
+ Project parent = project.getParent();
+ project.setParent( null );
+
+ // Interpolate
+d345 1
+a345 3
+
+ // Restore parent and context
+ project.setParent( parent );
+d369 16
+d422 80
+d674 1
+a674 1
+ if ( dominantMap == null )
+d713 1
+a713 1
+ Map result;
+a736 30
+ * Load the build.properties file for a project.
+ * @@param directory the directory of the project
+ * @@return the properties
+ */
+ private static Properties loadProjectBuildProperties( File directory )
+ {
+ // project build properties
+ File projectBuildPropertiesFile =
+ new File( directory, "build.properties" );
+
+ logger.debug( "Using projectBuildPropertiesFile: " + projectBuildPropertiesFile.getAbsolutePath() );
+ return loadProperties( projectBuildPropertiesFile );
+ }
+
+ /**
+ * Load the project.properties file for a project.
+ * @@param directory the directory of the project
+ * @@return the properties
+ */
+ private static Properties loadProjectProperties( File directory )
+ {
+ // project properties
+ File projectPropertiesFile =
+ new File( directory, "project.properties" );
+
+ logger.debug( "Using projectPropertiesFile: " + projectPropertiesFile.getAbsolutePath() );
+ return loadProperties( projectPropertiesFile );
+ }
+
+ /**
+a755 1
+ * @@todo should premerge driver, etc if they are being kept
+d772 13
+a784 2
+ Properties projectProperties = loadProjectProperties( descriptorDirectory );
+ Properties projectBuildProperties = loadProjectBuildProperties( descriptorDirectory );
+d840 2
+a841 2
+ context.setVariable( "basedir", descriptorDirectory.getAbsolutePath() );
+
+d883 1
+a883 1
+
+a1113 16
+ }
+
+ /**
+ * Get a list of goals from a CSV list.
+ * @@param goalCsv the goals
+ * @@return the list of goal names
+ */
+ public static List getGoalListFromCsv( String goalCsv )
+ {
+ StringTokenizer tok = new StringTokenizer( goalCsv, "," );
+ List goals = new ArrayList();
+ while ( tok.hasMoreTokens() )
+ {
+ goals.add( tok.nextToken() );
+ }
+ return goals;
+@
+
+
+1.107.4.2
+log
+@formatting, commenting
+@
+text
+@d110 1
+a110 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+d207 1
+@
+
+
+1.107.4.3
+log
+@Fix bug with werkz, better handling of plugins not being found, fix bug when no project.xml present
+@
+text
+@d110 1
+a110 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+a227 6
+// TODO [RC2] - check -vvv-
+ MavenJellyContext pContext = MavenUtils.createContext( projectDescriptor.getParentFile(),
+ parentContext );
+parent.setContext(pContext);
+context.setParent(pContext);
+// TODO [RC2] - check -^^^-
+@
+
+
+1.107.4.4
+log
+@cleanup project creation, make inheritence work
+@
+text
+@d110 1
+a110 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+d118 1
+a118 1
+ private static final Log log = LogFactory.getLog( MavenUtils.class );
+d169 1
+a169 26
+ * context.
+ *
+ * @@param projectDescriptor a maven project.xml {@@link File}
+ * @@param parentContext the parent context for the new project
+ * @@param useParentPom whether a parent project should be respected
+ * @@return the MavenSession project object for the given project descriptor
+ * @@throws Exception when any errors occur - TODO [RC2] bad
+ */
+ public static Project getProject( File projectDescriptor,
+ MavenJellyContext parentContext,
+ boolean useParentPom )
+ throws Exception
+ {
+ Project project = getNonJellyProject( projectDescriptor, parentContext, useParentPom );
+ project = getJellyProject( project );
+ project.setFile( projectDescriptor );
+
+ // Fully initialize the project.
+ project.initialize();
+
+ return project;
+ }
+
+ /**
+ * Get a project, but not a Jelly-ised project. ie Don't evaluate the
+ * variables. We are doing several things when creating a POM object, the phases
+d180 1
+a180 1
+ * 3) We check to see if the <extend> tag is being employed. If so, the parent
+d184 5
+a188 1
+ * @@param projectDescriptor the project file
+d191 2
+a192 2
+ * @@return the project
+ * @@throws Exception when any errors occur - TODO [RC2] bad
+d194 3
+a196 3
+ private static Project getNonJellyProject( File projectDescriptor,
+ MavenJellyContext parentContext,
+ boolean useParentPom )
+d199 2
+d205 2
+a206 2
+ MavenJellyContext context = MavenUtils.createContext( projectDescriptor.getParentFile(), parentContext );
+
+d225 1
+a225 1
+ parent = getNonJellyProject( parentPom, null, true );
+d228 6
+a233 2
+
+ context.setParent( parent.getContext() );
+d249 7
+d332 2
+a333 1
+ // Keep a copy of the original context
+d659 1
+a659 1
+ log.debug( "Using projectBuildPropertiesFile: " + projectBuildPropertiesFile.getAbsolutePath() );
+d674 1
+a674 1
+ log.debug( "Using projectPropertiesFile: " + projectPropertiesFile.getAbsolutePath() );
+d712 1
+a712 1
+ log.debug( "Using userBuildPropertiesFile: " + userBuildPropertiesFile.getAbsolutePath() );
+d753 1
+a753 1
+ //add in the default.properties with defaults, but in inheritance mode.
+d821 1
+a821 1
+ log.debug("Unexpected error evaluating expression", e);
+d842 1
+a842 1
+ log.debug("Unexpected error loading properties", e);
+d865 1
+a865 1
+ log.debug("Unexpected exception loading properties", e);
+d879 1
+a879 1
+ log.debug("Unexpected exception loading properties", e);
+@
+
+
+1.107.4.5
+log
+@PR: MAVEN-1107
+Add / to paths, use correct classloader for maven.jar
+@
+text
+@d110 1
+a110 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+d726 1
+a726 1
+ MavenUtils.class.getResourceAsStream(
+d730 1
+a730 1
+ MavenUtils.class.getResourceAsStream(
+@
+
+
+1.107.4.6
+log
+@Code cleanup
+@
+text
+@d110 1
+a110 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+d169 1
+a169 1
+ * context.
+d355 1
+a355 1
+
+d358 1
+a358 1
+
+d780 1
+a780 1
+
+d822 1
+a822 1
+
+d1064 1
+a1064 1
+ while ( tok.hasMoreTokens() )
+@
+
+
+1.107.4.7
+log
+@Optimize imports, reformatting by IDEA.
+@
+text
+@d59 21
+a103 20
+import javax.xml.parsers.SAXParserFactory;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+d110 1
+a110 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+@
+
+
+1.107.4.8
+log
+@reinstate useful debugging function
+@
+text
+@a58 1
+import com.werken.forehead.ForeheadClassLoader;
+a89 1
+import java.net.URL;
+d109 1
+a109 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+a1068 23
+
+ /**
+ * Debugging function.
+ * @@param project
+ * @@param classLoader
+ */
+ public static void displayClassLoaderContents( ForeheadClassLoader classLoader )
+ {
+ URL[] urls = classLoader.getURLs();
+
+ for ( int i = 0; i < urls.length; i++ )
+ {
+ System.out.println( "urls[" + i + "] = " + urls[i] );
+ }
+
+ ClassLoader parent = classLoader.getParent();
+ if ( parent != null && parent instanceof ForeheadClassLoader )
+ {
+ System.out.println( "Displaying Parent classloader: " );
+ displayClassLoaderContents( ( ForeheadClassLoader ) classLoader.getParent());
+ }
+ }
+
+@
+
+
+1.107.4.9
+log
+@improve logging output
+@
+text
+@d111 1
+a111 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+d845 1
+a845 4
+ if ( file.exists() )
+ {
+ return loadProperties( new FileInputStream (file) );
+ }
+@
+
+
+1.107.4.10
+log
+@fix possible NPE in reactor
+@
+text
+@d111 1
+a111 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+d245 1
+a245 1
+ parent = getNonJellyProject( parentPom, parentContext, true );
+@
+
+
+1.107.4.11
+log
+@Update to ASL v.2
+@
+text
+@d4 51
+a54 1
+ * Copyright 2001-2004 The Apache Software Foundation.
+a55 11
+ * Licensed 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.
+d111 1
+a111 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+@
+
+
+1.107.4.12
+log
+@show classloader name
+@
+text
+@d72 1
+a72 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+a1042 2
+ System.out.println( "ClassLoader name: " + classLoader.getName() );
+
+@
+
+
+1.107.4.13
+log
+@PR: MAVEN-1193
+Submitted by: dion gillard
+remove "throws Exception"
+@
+text
+@a44 1
+import javax.xml.parsers.ParserConfigurationException;
+a45 2
+
+import java.beans.IntrospectionException;
+d72 1
+a72 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+d108 1
+a108 1
+ * @@throws MavenException when any errors occur
+d111 1
+a111 1
+ throws MavenException
+d121 1
+a121 1
+ * @@throws MavenException when any error happens.
+d124 1
+a124 1
+ throws MavenException
+d137 1
+a137 1
+ * @@throws MavenException when any errors occur
+d142 1
+a142 1
+ throws MavenException
+d144 3
+a146 6
+ Project project = null;
+ try
+ {
+ project = getNonJellyProject( projectDescriptor, parentContext, useParentPom );
+ project = getJellyProject( project );
+ project.setFile( projectDescriptor );
+d148 2
+a149 19
+ // Fully initialize the project.
+ project.initialize();
+ }
+ catch (IntrospectionException e)
+ {
+ throw new MavenException("Error creating a string from the project", e);
+ }
+ catch (IOException e)
+ {
+ throw new MavenException("Error reading XML or initializing", e);
+ }
+ catch (ParserConfigurationException e)
+ {
+ throw new MavenException("Error creating a JAXP Parser", e);
+ }
+ catch (SAXException e)
+ {
+ throw new MavenException("Error parsing XML", e);
+ }
+d175 1
+a175 2
+ * @@throws MavenException when there are errors reading the descriptor
+ * @@throws IOException when resolving file names and paths
+d179 2
+a180 2
+ boolean useParentPom )
+ throws MavenException, IOException
+d183 1
+a183 9
+ Project project = null;
+ try
+ {
+ project = (Project) getProjectBeanReader().parse( projectDescriptor );
+ }
+ catch (Exception e)
+ {
+ throw new MavenException("Error parsing project.xml '" + projectDescriptor.getAbsolutePath() + "'");
+ }
+d236 1
+a236 1
+ * @@throws MavenException when anything goes wrong.
+d239 1
+a239 1
+ throws MavenException
+d252 1
+a252 1
+ * @@throws MavenException when anything goes wrong. FIXME this is bad
+d258 1
+a258 1
+ throws MavenException
+d278 1
+a278 3
+ * @@throws IntrospectionException when creating a bean reader
+ * @@throws SAXException when an error occurs parsing the XML
+ * @@throws ParserConfigurationException when a JAXP parser can't be created
+d280 2
+a281 1
+ private static BeanReader getProjectBeanReader() throws IntrospectionException, SAXException, ParserConfigurationException
+d297 1
+a297 4
+ * @@throws IntrospectionException when there are errors creating a string from the project for interpolation
+ * @@throws SAXException when reading the interpolated POM fails
+ * @@throws IOException when there are errors reading
+ * @@throws ParserConfigurationException when a JAXP parser can't be created
+d299 2
+a300 2
+ private static Project getJellyProject( Project project )
+ throws IOException, SAXException, IntrospectionException, ParserConfigurationException
+d334 1
+a336 2
+ * @@throws IntrospectionException when there are errors creating a string from the project
+ * @@throws ParserConfigurationException when a JAXP parser can't be created
+d339 1
+a339 1
+ throws IOException, SAXException, IntrospectionException, ParserConfigurationException
+d351 1
+a351 3
+ * @@throws IOException when reading the string fails
+ * @@throws SAXException when parsing the interpolated POM fails
+ * @@throws IntrospectionException when writing the POM to XML
+d354 1
+a354 1
+ throws MavenException
+d356 1
+a356 16
+ try
+ {
+ return new StringInputStream( getProjectString( project ) );
+ }
+ catch (IOException e)
+ {
+ throw new MavenException("Error writing the project",e);
+ }
+ catch (IntrospectionException e)
+ {
+ throw new MavenException("Error introspecting the project", e);
+ }
+ catch (SAXException e)
+ {
+ throw new MavenException("Error parsing the project as XML", e);
+ }
+d364 1
+a364 3
+ * @@throws IOException writing the project fails
+ * @@throws IntrospectionException when there are problems writing the project bean as a string
+ * @@throws SAXException when there are problems writing the project bean as a string
+d366 2
+a367 1
+ private static String getProjectString( Project project ) throws IOException, IntrospectionException, SAXException
+d437 3
+a439 3
+ * @@throws IntrospectionException when there are errors registering the provided class
+ * @@throws SAXException when there are errors getting an XML reader
+ * @@throws ParserConfigurationException when there are errors getting an XML reader
+d441 2
+a442 2
+ public static BeanReader createBeanReader( Class clazz )
+ throws IntrospectionException, SAXException, ParserConfigurationException
+d492 1
+a492 2
+ * @@throws SAXException when the reader can't be created
+ * @@throws ParserConfigurationException when the reader can't be created
+d494 2
+a495 1
+ public static XMLReader getXMLReader() throws SAXException, ParserConfigurationException
+d510 1
+a510 2
+ * @@throws SAXException If there are errors creating the reader
+ * @@throws ParserConfigurationException If there are errors creating the SAX parser to use
+d512 2
+a513 1
+ private static XMLReader createXMLReader() throws SAXException, ParserConfigurationException
+d770 1
+a770 1
+ value = map.get( key );
+d772 1
+a772 1
+ if ( value instanceof String )
+d774 3
+a776 1
+ try
+d778 1
+a778 11
+ String literalValue = (String) value;
+ Expression expr = CompositeExpression.parse( literalValue, factory );
+
+ if ( expr != null )
+ {
+ value = expr;
+ }
+ else
+ {
+ value = literalValue;
+ }
+d780 1
+a780 1
+ catch ( Exception e )
+d782 1
+a782 2
+ // do nothing.
+ log.debug( "Unexpected error evaluating expression", e );
+d784 7
+a791 1
+ context.setVariable( key, value );
+d885 1
+d888 1
+d897 1
+d900 1
+@
+
+
+1.107.4.14
+log
+@need to set these properties each time - integrateMap will not override them
+@
+text
+@d75 1
+a75 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+d827 1
+a827 1
+ try
+d829 4
+a832 2
+ String literalValue = (String) value;
+ Expression expr = CompositeExpression.parse( literalValue, factory );
+d834 8
+a841 3
+ if ( expr != null )
+ {
+ value = expr;
+d843 1
+a843 1
+ else
+d845 2
+a846 1
+ value = literalValue;
+a847 5
+ }
+ catch ( Exception e )
+ {
+ // do nothing.
+ log.debug( "Unexpected error evaluating expression", e );
+@
+
+
+1.107.4.15
+log
+@Fix some checkstyle errors
+@
+text
+@d75 1
+a75 1
+ * @@version $Id: MavenUtils.java,v,v 1.1.1.1 2004/10/22 12:29:49 evenisse Exp $
+d148 1
+a148 1
+ try
+d203 1
+a203 1
+ boolean useParentPom )
+d210 1
+a210 1
+ project = (Project) getProjectBeanReader().parse( projectDescriptor );
+d214 1
+a214 1
+ throw new MavenException("Error parsing project.xml '" + projectDescriptor.getAbsolutePath() + "'");
+d314 1
+a314 2
+ private static BeanReader getProjectBeanReader()
+ throws IntrospectionException, SAXException, ParserConfigurationException
+d335 2
+a336 2
+ private static Project getJellyProject( Project project )
+ throws IOException, SAXException, IntrospectionException, ParserConfigurationException
+d388 3
+a390 1
+ * @@throws MavenException when reading the project
+d401 1
+a401 1
+ throw new MavenException("Error writing the project", e);
+d496 1
+a496 1
+ public static BeanReader createBeanReader( Class clazz )
+d831 1
+a831 1
+
+d1089 2
+a1090 1
[... 5245 lines stripped ...]