Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Subversive » 2 possible bugs in Subversive Fetch Factory
2 possible bugs in Subversive Fetch Factory [message #44470] Mon, 13 April 2009 14:47 Go to next message
Shaoying Yang is currently offline Shaoying YangFriend
Messages: 13
Registered: July 2009
Junior Member
Dear all, especially Mr. Alexander Gurov,

I am trying to use the Subversive Fetch Factory. Per
https://bugs.eclipse.org/bugs/show_bug.cgi?id=227115, it is ready to use. I
have concluded that there are two possible bugs/enhancements that I'd like
you to confirm before I create a bugzilla item.

The first one was not supporting force in the SVN ant task for the export
command. This one is easy and trivial.
// in SVNTask.java
else if (SVNTask.CMD_EXPORT.equals(this.command)) {
cmdLine = "svn export ";

// 4/8/2009 1:14PM Shawn: Added force when exporting
if (this.force == true) {
cmdLine += " --force ";
}

if (this.rev != null) {
cmdLine += " -r " + this.rev;
}

cmdLine += " " + this.SPACE_WRAP_CHAR + this.url;
if (this.pegRev != null) {
cmdLine += "@" + this.pegRev;
}
cmdLine += this.SPACE_WRAP_CHAR;
cmdLine += " " + this.SPACE_WRAP_CHAR + this.dest + this.SPACE_WRAP_CHAR;
cmdLine += this.getCreadentialsPart();
cmdLine += " -q --non-interactive";
}


The second one is more complicated.

The Eclipse BaseBuilder uses Subversive Fetch Factory to calculate tag. In
the
IFetchFactory, it is specified explicitly that the value of tag can't
contain
characters like "/". The Subversive Fetch Factory didn't guard this
constraint. It set the whole thing "tags/nightly/20093...." as the value of
this key. This leads to build errors.

The following is an excerpt from the IFetchFactory interface

/** Key used to store the value of the tag that will be used to fetch
the element.
* <p>
* The grammar of the expected value is limited to:
* <pre>
* value::= (alpha|digit|'_'|'-')+
* digit ::= [0..9]
* alpha ::= [a..zA..Z]
* </pre>
* */
public static final String KEY_ELEMENT_TAG = "tag"; //$NON-NLS-1$

The following is the proposed modified code for the class SVNFetchFactory

/*********************************************************** ********************
* Copyright (c) 2005-2006 Polarion Software.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alexander Gurov (Polarion Software) - initial API and
implementation
************************************************************ *******************/

package org.eclipse.team.svn.pde.build;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.pde.build.Constants;
import org.eclipse.pde.build.IAntScript;
import org.eclipse.pde.build.IFetchFactory;
import org.eclipse.pde.internal.build.Utils;

/**
* Implementation of SVN fetch task factory for PDE build
*
* @author Alexander Gurov
*/
public class SVNFetchFactory implements IFetchFactory {
public static final String TARGET_FETCH_FROM_SVN = "FetchFromSVN";
public static final String MAP_ENTRY_SEPARATOR = ",";
public static final String VALUE_PAIR_SEPARATOR = "=";

public static final String OVERRIDE_TAG = "SVN";

public static final String KEY_URL = "url";
public static final String KEY_PEG = "peg";
public static final String KEY_REVISION = "revision";
public static final String KEY_PATH = "path";
public static final String KEY_USERNAME = "username";
public static final String KEY_PASSWORD = "password";

public static final String PROP_FILETOCHECK = "fileToCheck";
public static final String PROP_ELEMENTNAME = "elementName";
public static final String PROP_DESTINATIONFOLDER =
"destinationFolder";
public static final String PROP_URL = SVNFetchFactory.KEY_URL;
public static final String PROP_PEG = SVNFetchFactory.KEY_PEG;
public static final String PROP_REVISION =
SVNFetchFactory.KEY_REVISION;
public static final String PROP_TAG = IFetchFactory.KEY_ELEMENT_TAG;
public static final String PROP_PATH = SVNFetchFactory.KEY_PATH;
public static final String PROP_USERNAME =
SVNFetchFactory.KEY_USERNAME;
public static final String PROP_PASSWORD =
SVNFetchFactory.KEY_PASSWORD;

private static String overrideTag = "";

public SVNFetchFactory() {

}

public void addTargets(IAntScript script) {
script.printTargetDeclaration(SVNFetchFactory.TARGET_FETCH_F ROM_SVN,
null, null, "${" + SVNFetchFactory.PROP_FILETOCHECK + "}", null);
this.printSVNTask("export", "${" + SVNFetchFactory.PROP_URL + "}/${" +
SVNFetchFactory.PROP_TAG + "}/${" + SVNFetchFactory.PROP_PATH + "}", "${" +
SVNFetchFactory.PROP_PEG + "}", "${" + SVNFetchFactory.PROP_REVISION + "}",
"${" + SVNFetchFactory.PROP_DESTINATIONFOLDER + "}/${" +
SVNFetchFactory.PROP_ELEMENTNAME + "}", "${" + SVNFetchFactory.PROP_USERNAME
+ "}", "${" + SVNFetchFactory.PROP_PASSWORD + "}", script);
script.printTargetEnd();
}

public void generateRetrieveElementCall(Map entryInfos, IPath
destination, IAntScript script) {
String type = (String) entryInfos.get(KEY_ELEMENT_TYPE);
String element = (String) entryInfos.get(KEY_ELEMENT_NAME);

HashMap<String, String> params = new HashMap<String, String>();

IPath locationToCheck = (IPath)destination.clone();
if (type.equals(ELEMENT_TYPE_FEATURE)) {
locationToCheck =
locationToCheck.append(Constants.FEATURE_FILENAME_DESCRIPTOR );
}
else if (type.equals(ELEMENT_TYPE_PLUGIN)) {
locationToCheck =
locationToCheck.append(Constants.PLUGIN_FILENAME_DESCRIPTOR) ;
}
else if (type.equals(ELEMENT_TYPE_FRAGMENT)) {
locationToCheck =
locationToCheck.append(Constants.FRAGMENT_FILENAME_DESCRIPTO R);
}
else if (type.equals(ELEMENT_TYPE_BUNDLE)) {
locationToCheck =
locationToCheck.append(Constants.BUNDLE_FILENAME_DESCRIPTOR) ;
}
params.put(SVNFetchFactory.PROP_ELEMENTNAME, element);
params.put(SVNFetchFactory.PROP_FILETOCHECK,
locationToCheck.toString());
params.put(SVNFetchFactory.PROP_DESTINATIONFOLDER,
destination.removeLastSegments(1).toString());
params.put(SVNFetchFactory.PROP_URL,
(String)entryInfos.get(SVNFetchFactory.KEY_URL));
if (entryInfos.containsKey(SVNFetchFactory.KEY_PEG)) {
params.put(SVNFetchFactory.PROP_PEG,
(String)entryInfos.get(SVNFetchFactory.KEY_PEG));
}
else {
params.put(SVNFetchFactory.PROP_PEG, "HEAD");
}
if (entryInfos.containsKey(SVNFetchFactory.KEY_REVISION)) {
params.put(SVNFetchFactory.PROP_REVISION,
(String)entryInfos.get(SVNFetchFactory.KEY_REVISION));
}
else {
params.put(SVNFetchFactory.PROP_REVISION, "HEAD");
}
params.put(SVNFetchFactory.PROP_TAG, SVNFetchFactory.overrideTag);
params.put(SVNFetchFactory.PROP_PATH,
(String)entryInfos.get(SVNFetchFactory.KEY_PATH));
String username =
(String)entryInfos.get(SVNFetchFactory.KEY_USERNAME);
params.put(SVNFetchFactory.PROP_USERNAME, username != null ? username
: "");
String password =
(String)entryInfos.get(SVNFetchFactory.KEY_PASSWORD);
params.put(SVNFetchFactory.PROP_PASSWORD, password != null ? password
: "");

this.printAvailableTask(locationToCheck.toString(),
locationToCheck.toString(), script);
if (IFetchFactory.ELEMENT_TYPE_PLUGIN.equals(type) ||
IFetchFactory.ELEMENT_TYPE_FRAGMENT.equals(type)) {
this.printAvailableTask(locationToCheck.toString(),
locationToCheck.removeLastSegments(1).append(Constants.BUNDL E_FILENAME_DESCRIPTOR).toString(),
script);
}

script.printAntCallTask(SVNFetchFactory.TARGET_FETCH_FROM_SV N, true,
params);
}

public void generateRetrieveFilesCall(Map entryInfos, IPath
destination, String[] files, IAntScript script) {
String rootUrl = (String)entryInfos.get(SVNFetchFactory.KEY_URL);
String pegRev = (String)entryInfos.get(SVNFetchFactory.KEY_PEG);
String rev = (String)entryInfos.get(SVNFetchFactory.KEY_REVISION);

String tag = SVNFetchFactory.overrideTag;

String path = (String)entryInfos.get(SVNFetchFactory.KEY_PATH);

String baseUrl = rootUrl + "/" + tag + "/" + path + "/";
String dest = destination.toString();

String username =
(String)entryInfos.get(SVNFetchFactory.KEY_USERNAME);
String password =
(String)entryInfos.get(SVNFetchFactory.KEY_PASSWORD);
for (String fileName : files) {
this.printSVNTask("cat", baseUrl + fileName, pegRev, rev, dest + "/"
+ fileName, username, password, script);
}
}

/*
* Map file entry format:
* mapEntry
* : elementType '@' elementID (',' elementVersion)? = svnContent
* ;
* elementType
* : 'bundle' | 'feature' | 'plugin' | 'fragment'
* ;
* elementID
* : ... //plug-in, feature, fragment or bundle ID
* ;
* elementVersion
* : ... //plug-in, feature, fragment or bundle version
* ;
* svnContent
* : 'SVN' (',' arg)+
* ;
* arg
* : key '=' value
* ;
* key
* : 'url' // project root URL
* | 'tag' // optional tag name (trunk, tags/some_name etc.)
* | 'path' // optional element, path relative to project root URL
* | 'revision' // optional element, revision
* | 'peg' // optional element, peg revision
* | 'username'
* | 'password'
* ;
*/
public void parseMapFileEntry(String rawEntry, Properties overrideTags,
Map entryInfos) throws CoreException {
String []arguments = Utils.getArrayFromStringWithBlank(rawEntry,
SVNFetchFactory.MAP_ENTRY_SEPARATOR);

// check entry count here....
for (String argument : arguments) {
int idx = argument.indexOf(SVNFetchFactory.VALUE_PAIR_SEPARATOR);
if (idx != -1) {
String key = argument.substring(0, idx);
String value = argument.substring(idx + 1);
entryInfos.put(key, value);
}
}

if (overrideTags != null) {
SVNFetchFactory.overrideTag =
overrideTags.getProperty(SVNFetchFactory.OVERRIDE_TAG);
if (SVNFetchFactory.overrideTag != null &&
SVNFetchFactory.overrideTag.length() > 0) {

StringTokenizer st = new
StringTokenizer(SVNFetchFactory.overrideTag, "/");
String lastToken = null;
while (st.hasMoreTokens() == true) {
lastToken = st.nextToken();
}
entryInfos.put(IFetchFactory.KEY_ELEMENT_TAG, lastToken);
}
}
// handle optional path
String path = (String)entryInfos.get(SVNFetchFactory.KEY_PATH);
if (path == null) {
entryInfos.put(SVNFetchFactory.KEY_PATH,
entryInfos.get(IFetchFactory.KEY_ELEMENT_NAME));
}
// handle optional tag
String tag = (String)entryInfos.get(IFetchFactory.KEY_ELEMENT_TAG);
if (tag == null) {
entryInfos.put(IFetchFactory.KEY_ELEMENT_TAG, "");
}
}

protected void printSVNTask(String command, String url, String pegRev,
String rev, String dest, String username, String password, IAntScript
script) {
script.printTabs();
script.print("<svn");
script.printAttribute("command", command, false);
script.printAttribute("url", url, false);
script.printAttribute("pegRev", pegRev, false);
script.printAttribute("rev", rev, false);
script.printAttribute("dest", dest, false);
script.printAttribute("username", username, false);
script.printAttribute("password", password, false);
script.println("/>");
}

protected void printAvailableTask(String property, String file,
IAntScript script) {
script.printTabs();
script.print("<available");
script.printAttribute("property", property, true);
script.printAttribute("file", file, false);
script.println("/>");
}

}
Re: 2 possible bugs in Subversive Fetch Factory [message #44721 is a reply to message #44470] Mon, 20 April 2009 13:23 Go to previous messageGo to next message
Shaoying Yang is currently offline Shaoying YangFriend
Messages: 13
Registered: July 2009
Junior Member
I found the 3rd possible bug/enhancement for the Subversive Fetch Factory.

Original code doesn't support same plugin with multiple plugins to be
downloaded into ${buildDirectory}/plugins/
example:
com.shawn.bundles.axis (1.2.1)
com.shawn.bundles.axis (1.4.0)
both specified in feature.xml and .map

The fetch script generated by original code always trying to download to one
folder called
${buildDirectory}/plugins/com.shawn.bundles.axis
Unlike CVSFetchFactory, if you specify a version to the plugin in the map,
for example, 'plugin@xxx,1.2.1=...' it will download to
${buildDirectory}/plugins/com.shawn.bundles.axis_1.2.1 and
${buildDirectory}/plugins/com.shawn.bundles.axis_1.4.0 respectively.
This is needed when we want to build multiple versions of the same bundle in
a PDE project like Orbit or Shawn Commons.

// original code
// params.put(SVNFetchFactory.PROP_ELEMENTNAME, element);

The following patch will solve the problem.
// begin of the patch
if(org.osgi.framework.Version.emptyVersion.equals(entryInfos .get( "internal.matchedVersion"))){ params.put(SVNFetchFactory.PROP_ELEMENTNAME, element); } else { params.put(SVNFetchFactory.PROP_ELEMENTNAME, element + "_" +entryInfos.get("internal.matchedVersion")); } // end of the patch--------------------The following is the complete copy of the Subversive Fetch Factory, with all3 proposed fix.--------------------/*********************************** ******************************************** * Copyright (c) 2005-2006 Polarion Software. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Alexander Gurov (Polarion Software) - initial API and implementation ************************************************************ *******************/package org.eclipse.team.svn.pde.build;import java.util.HashMap;import java.util.Map;import java.util.Properties;import java.util.StringTokenizer;import org.eclipse.core.runtime.CoreException;import org.eclipse.core.runtime.IPath;import org.eclipse.pde.build.Constants;import org.eclipse.pde.build.IAntScript;import org.eclipse.pde.build.IFetchFactory;import org.eclipse.pde.internal.build.Utils;/** * Implementation of SVN fetch task factory for PDE build * * @author Alexander Gurov */public class SVNFetchFactory implements IFetchFactory { public static final String TARGET_FETCH_FROM_SVN = "FetchFromSVN"; public static final String MAP_ENTRY_SEPARATOR = ","; public static final String VALUE_PAIR_SEPARATOR = "="; public static final String OVERRIDE_TAG = "SVN"; public static final String KEY_URL = "url"; public static final String KEY_PEG = "peg"; public static final String KEY_REVISION = "revision"; public static final String KEY_PATH = "path"; public static final String KEY_USERNAME = "username"; public static final String KEY_PASSWORD = "password"; public static final String PROP_FILETOCHECK = "fileToCheck"; public static final String PROP_ELEMENTNAME = "elementName"; public static final String PROP_DESTINATIONFOLDER = "destinationFolder"; public static final String PROP_URL = SVNFetchFactory.KEY_URL; public static final String PROP_PEG = SVNFetchFactory.KEY_PEG; public static final String PROP_REVISION = SVNFetchFactory.KEY_REVISION; public static final String PROP_TAG = IFetchFactory.KEY_ELEMENT_TAG; public static final String PROP_PATH = SVNFetchFactory.KEY_PATH; public static final String PROP_USERNAME = SVNFetchFactory.KEY_USERNAME; public static final String PROP_PASSWORD = SVNFetchFactory.KEY_PASSWORD; private static String overrideTag = ""; public SVNFetchFactory() { } public void addTargets(IAntScript script) { script.printTargetDeclaration(SVNFetchFactory.TARGET_FETCH_F ROM_SVN, null,null, "${" + SVNFetchFactory.PROP_FILETOCHECK + "}", null); this.printSVNTask("export", "${" + SVNFetchFactory.PROP_URL + "}/${" +SVNFetchFactory.PROP_TAG + "}/${" + SVNFetchFactory.PROP_PATH + "}", "${" +SVNFetchFactory.PROP_PEG + "}", "${" + SVNFetchFactory.PROP_REVISION + "}","${" + SVNFetchFactory.PROP_DESTINATIONFOLDER + "}/${" +SVNFetchFactory.PROP_ELEMENTNAME + "}", "${" + SVNFetchFactory.PROP_USERNAME+ "}", "${" + SVNFetchFactory.PROP_PASSWORD + "}", script); script.printTargetEnd(); } public void generateRetrieveElementCall(Map entryInfos, IPath destination,IAntScript script) { String type = (String) entryInfos.get(KEY_ELEMENT_TYPE); String element = (String) entryInfos.get(KEY_ELEMENT_NAME); HashMap<String, String> params = new HashMap<String, String>(); IPath locationToCheck = (IPath)destination.clone(); if (type.equals(ELEMENT_TYPE_FEATURE)) { locationToCheck =locationToCheck.append(Constants.FEATURE_FILENAME_DESCRIPTO R); } else if (type.equals(ELEMENT_TYPE_PLUGIN)) { locationToCheck =locationToCheck.append(Constants.PLUGIN_FILENAME_DESCRIPTOR ); } else if (type.equals(ELEMENT_TYPE_FRAGMENT)) { locationToCheck =locationToCheck.append(Constants.FRAGMENT_FILENAME_DESCRIPT OR); } else if (type.equals(ELEMENT_TYPE_BUNDLE)) { locationToCheck =locationToCheck.append(Constants.BUNDLE_FILENAME_DESCRIPTOR ); } /* original code doesn't support same plugin with multiple plugins to be downloaded into ${buildDirectory}/plugins/ example: com.compuware.bundles.axis (1.2.1) com.compuware.bundles.axis (1.4.0) both specified in feature.xml and .map The fetch script generated by original code always trying to download to one folder called ${buildDirectory}/plugins/com.compuware.bundles.axis Do not like CVSFetchFactory, if you specify a version to the plugin inthe map, for example, 'plugin@xxx,1.2.1=...' it will download to ${buildDirectory}/plugins/com.compuware.bundles.axis_1.2.1 and ${buildDirectory}/plugins/com.compuware.bundles.axis_1.4.0re spectively. This is needed when we want to build multiple versions of same bundle ina project like Orbit or Compuware Commons. The following patch will solve the problem. */ // original code // params.put(SVNFetchFactory.PROP_ELEMENTNAME, element); // begin of the patch if(org.osgi.framework.Version.emptyVersion.equals(entryInfos .get( "internal.matchedVersion"))) { params.put(SVNFetchFactory.PROP_ELEMENTNAME, element); } else { params.put(SVNFetchFactory.PROP_ELEMENTNAME, element + "_" +entryInfos.get("internal.matchedVersion")); } // end of the patch params.put(SVNFetchFactory.PROP_FILETOCHECK, locationToCheck.toString()); params.put(SVNFetchFactory.PROP_DESTINATIONFOLDER,destinatio n.removeLastSegments(1).toString()); params.put(SVNFetchFactory.PROP_URL,(String)entryInfos.get(S VNFetchFactory.KEY_URL)); if (entryInfos.containsKey(SVNFetchFactory.KEY_PEG)) { params.put(SVNFetchFactory.PROP_PEG,(String)entryInfos.get(S VNFetchFactory.KEY_PEG)); } else { params.put(SVNFetchFactory.PROP_PEG, "HEAD"); } if (entryInfos.containsKey(SVNFetchFactory.KEY_REVISION)) { params.put(SVNFetchFactory.PROP_REVISION,(String)entryInfos. get(SVNFetchFactory.KEY_REVISION)); } else { params.put(SVNFetchFactory.PROP_REVISION, "HEAD"); } params.put(SVNFetchFactory.PROP_TAG, SVNFetchFactory.overrideTag); params.put(SVNFetchFactory.PROP_PATH,(String)entryInfos.get( SVNFetchFactory.KEY_PATH)); String username = (String)entryInfos.get(SVNFetchFactory.KEY_USERNAME); params.put(SVNFetchFactory.PROP_USERNAME, username != null ? username :""); String password = (String)entryInfos.get(SVNFetchFactory.KEY_PASSWORD); params.put(SVNFetchFactory.PROP_PASSWORD, password != null ? password :""); this.printAvailableTask(locationToCheck.toString(),locationT oCheck.toString(), script); if (IFetchFactory.ELEMENT_TYPE_PLUGIN.equals(type) ||IFetchFactory.ELEMENT_TYPE_FRAGMENT.equals(type)) { this.printAvailableTask(locationToCheck.toString(),locationT oCheck.removeLastSegments(1).append(Constants.BUNDLE_FILENAM E_DESCRIPTOR).toString(), script); } script.printAntCallTask(SVNFetchFactory.TARGET_FETCH_FROM_SV N, true,params); } public void generateRetrieveFilesCall(Map entryInfos, IPath destination,String[] files, IAntScript script) { String rootUrl = (String)entryInfos.get(SVNFetchFactory.KEY_URL); String pegRev = (String)entryInfos.get(SVNFetchFactory.KEY_PEG); String rev = (String)entryInfos.get(SVNFetchFactory.KEY_REVISION); String tag = SVNFetchFactory.overrideTag; String path = (String)entryInfos.get(SVNFetchFactory.KEY_PATH); String baseUrl = rootUrl + "/" + tag + "/" + path + "/"; String dest = destination.toString(); String username = (String)entryInfos.get(SVNFetchFactory.KEY_USERNAME); String password = (String)entryInfos.get(SVNFetchFactory.KEY_PASSWORD); for (String fileName : files) { this.printSVNTask("cat", baseUrl + fileName, pegRev, rev, dest + "/" +fileName, username, password, script); } } /* * Map file entry format: * mapEntry * : elementType '@' elementID (',' elementVersion)? = svnContent * ; * elementType * : 'bundle' | 'feature' | 'plugin' | 'fragment' * ; * elementID * : ... //plug-in, feature, fragment or bundle ID * ; * elementVersion * : ... //plug-in, feature, fragment or bundle version * ; * svnContent * : 'SVN' (',' arg)+ * ; * arg * : key '=' value * ; * key * : 'url' // project root URL * | 'tag' // optional tag name (trunk, tags/some_name etc.) * | 'path' // optional element, path relative to project root URL * | 'revision' // optional element, revision * | 'peg' // optional element, peg revision * | 'username' * | 'password' * ; */ public void parseMapFileEntry(String rawEntry, Properties overrideTags, MapentryInfos) throws CoreException { String []arguments = Utils.getArrayFromStringWithBlank(rawEntry,SVNFetchFactory.M AP_ENTRY_SEPARATOR); // check entry count here.... for (String argument : arguments) { int idx = argument.indexOf(SVNFetchFactory.VALUE_PAIR_SEPARATOR); if (idx != -1) { String key = argument.substring(0, idx); String value = argument.substring(idx + 1); entryInfos.put(key, value); } } if (overrideTags != null) { SVNFetchFactory.overrideTag =overrideTags.getProperty(SVNFetchFactory.OVERRIDE_TAG); if (SVNFetchFactory.overrideTag != null &&SVNFetchFactory.overrideTag.length() > 0) { StringTokenizer st = new StringTokenizer(SVNFetchFactory.overrideTag,"/"); String lastToken = null; while (st.hasMoreTokens() == true) { lastToken = st.nextToken(); } entryInfos.put(IFetchFactory.KEY_ELEMENT_TAG, lastToken); } } // handle optional path String path = (String)entryInfos.get(SVNFetchFactory.KEY_PATH); if (path == null) { entryInfos.put(SVNFetchFactory.KEY_PATH,entryInfos.get(IFetc hFactory.KEY_ELEMENT_NAME)); } // handle optional tag String tag = (String)entryInfos.get(IFetchFactory.KEY_ELEMENT_TAG); if (tag == null) { entryInfos.put(IFetchFactory.KEY_ELEMENT_TAG, ""); } } protected void printSVNTask(String command, String url, String pegRev,String rev, String dest, String username, String password, IAntScriptscript) { script.printTabs(); script.print("<svn"); script.printAttribute("command", command, false); script.printAttribute("url", url, false); script.printAttribute("pegRev", pegRev, false); script.printAttribute("rev", rev, false); script.printAttribute("dest", dest, false); script.printAttribute("username", username, false); script.printAttribute("password", password, false); script.println("/>"); } protected void printAvailableTask(String property, String file, IAntScriptscript) { script.printTabs(); script.print("<available"); script.printAttribute("property", property, true); script.printAttribute("file", file, false); script.println("/>"); }}
Re: 2 possible bugs in Subversive Fetch Factory [message #44825 is a reply to message #44721] Wed, 22 April 2009 10:59 Go to previous message
Igor Burilo is currently offline Igor BuriloFriend
Messages: 435
Registered: July 2009
Senior Member
Hello Shawn,

I created a bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=273230.
Could you please attach your patch there and we'll review it?
Thanks a lot.

>I found the 3rd possible bug/enhancement for the Subversive Fetch Factory.
>
> Original code doesn't support same plugin with multiple plugins to be
> downloaded into ${buildDirectory}/plugins/
> example:
> com.shawn.bundles.axis (1.2.1)
> com.shawn.bundles.axis (1.4.0)
> both specified in feature.xml and .map
>
> The fetch script generated by original code always trying to download to
> one folder called
> ${buildDirectory}/plugins/com.shawn.bundles.axis
> Unlike CVSFetchFactory, if you specify a version to the plugin in the map,
> for example, 'plugin@xxx,1.2.1=...' it will download to
> ${buildDirectory}/plugins/com.shawn.bundles.axis_1.2.1 and
> ${buildDirectory}/plugins/com.shawn.bundles.axis_1.4.0 respectively.
> This is needed when we want to build multiple versions of the same bundle
> in a PDE project like Orbit or Shawn Commons.
>
> // original code
> // params.put(SVNFetchFactory.PROP_ELEMENTNAME, element);
>
> The following patch will solve the problem.
> // begin of the patch
> if(org.osgi.framework.Version.emptyVersion.equals(entryInfos .get( "internal.matchedVersion"))){
> params.put(SVNFetchFactory.PROP_ELEMENTNAME, element); } else {
> params.put(SVNFetchFactory.PROP_ELEMENTNAME, element + "_"
> +entryInfos.get("internal.matchedVersion")); } // end of the
> patch--------------------The following is the complete copy of the
> Subversive Fetch Factory, with all3 proposed
> fix.--------------------/*********************************** ********************************************
> * Copyright (c) 2005-2006 Polarion Software. * All rights reserved. This
> program and the accompanying materials * are made available under the
> terms of the Eclipse Public License v1.0 * which accompanies this
> distribution, and is available at *
> http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Alexander
> Gurov (Polarion Software) - initial API and implementation
> ************************************************************ *******************/package
> org.eclipse.team.svn.pde.build;import java.util.HashMap;import
> java.util.Map;import java.util.Properties;import
> java.util.StringTokenizer;import
> org.eclipse.core.runtime.CoreException;import
> org.eclipse.core.runtime.IPath;import
> org.eclipse.pde.build.Constants;import
> org.eclipse.pde.build.IAntScript;import
> org.eclipse.pde.build.IFetchFactory;import
> org.eclipse.pde.internal.build.Utils;/** * Implementation of SVN fetch
> task factory for PDE build * * @author Alexander Gurov */public class
> SVNFetchFactory implements IFetchFactory { public static final String
> TARGET_FETCH_FROM_SVN = "FetchFromSVN"; public static final String
> MAP_ENTRY_SEPARATOR = ","; public static final String VALUE_PAIR_SEPARATOR
> = "="; public static final String OVERRIDE_TAG = "SVN"; public static
> final String KEY_URL = "url"; public static final String KEY_PEG = "peg";
> public static final String KEY_REVISION = "revision"; public static final
> String KEY_PATH = "path"; public static final String KEY_USERNAME =
> "username"; public static final String KEY_PASSWORD = "password"; public
> static final String PROP_FILETOCHECK = "fileToCheck"; public static final
> String PROP_ELEMENTNAME = "elementName"; public static final String
> PROP_DESTINATIONFOLDER = "destinationFolder"; public static final String
> PROP_URL = SVNFetchFactory.KEY_URL; public static final String PROP_PEG =
> SVNFetchFactory.KEY_PEG; public static final String PROP_REVISION =
> SVNFetchFactory.KEY_REVISION; public static final String PROP_TAG =
> IFetchFactory.KEY_ELEMENT_TAG; public static final String PROP_PATH =
> SVNFetchFactory.KEY_PATH; public static final String PROP_USERNAME =
> SVNFetchFactory.KEY_USERNAME; public static final String PROP_PASSWORD =
> SVNFetchFactory.KEY_PASSWORD; private static String overrideTag = "";
> public SVNFetchFactory() { } public void addTargets(IAntScript script)
> { script.printTargetDeclaration(SVNFetchFactory.TARGET_FETCH_F ROM_SVN,
> null,null, "${" + SVNFetchFactory.PROP_FILETOCHECK + "}", null);
> this.printSVNTask("export", "${" + SVNFetchFactory.PROP_URL + "}/${"
> +SVNFetchFactory.PROP_TAG + "}/${" + SVNFetchFactory.PROP_PATH + "}", "${"
> +SVNFetchFactory.PROP_PEG + "}", "${" + SVNFetchFactory.PROP_REVISION +
> "}","${" + SVNFetchFactory.PROP_DESTINATIONFOLDER + "}/${"
> +SVNFetchFactory.PROP_ELEMENTNAME + "}", "${" +
> SVNFetchFactory.PROP_USERNAME+ "}", "${" + SVNFetchFactory.PROP_PASSWORD +
> "}", script); script.printTargetEnd(); } public void
> generateRetrieveElementCall(Map entryInfos, IPath destination,IAntScript
> script) { String type = (String) entryInfos.get(KEY_ELEMENT_TYPE);
> String element = (String) entryInfos.get(KEY_ELEMENT_NAME);
> HashMap<String, String> params = new HashMap<String, String>(); IPath
> locationToCheck = (IPath)destination.clone(); if
> (type.equals(ELEMENT_TYPE_FEATURE)) { locationToCheck
> =locationToCheck.append(Constants.FEATURE_FILENAME_DESCRIPTO R); } else
> if (type.equals(ELEMENT_TYPE_PLUGIN)) { locationToCheck
> =locationToCheck.append(Constants.PLUGIN_FILENAME_DESCRIPTOR ); } else if
> (type.equals(ELEMENT_TYPE_FRAGMENT)) { locationToCheck
> =locationToCheck.append(Constants.FRAGMENT_FILENAME_DESCRIPT OR); } else
> if (type.equals(ELEMENT_TYPE_BUNDLE)) { locationToCheck
> =locationToCheck.append(Constants.BUNDLE_FILENAME_DESCRIPTOR ); } /*
> original code doesn't support same plugin with multiple plugins to be
> downloaded into ${buildDirectory}/plugins/ example:
> com.compuware.bundles.axis (1.2.1) com.compuware.bundles.axis
> (1.4.0) both specified in feature.xml and .map The fetch script
> generated by original code always trying to download to one folder
> called ${buildDirectory}/plugins/com.compuware.bundles.axis Do not
> like CVSFetchFactory, if you specify a version to the plugin inthe map,
> for example, 'plugin@xxx,1.2.1=...' it will download to
> ${buildDirectory}/plugins/com.compuware.bundles.axis_1.2.1 and
> ${buildDirectory}/plugins/com.compuware.bundles.axis_1.4.0re spectively.
> This is needed when we want to build multiple versions of same bundle ina
> project like Orbit or Compuware Commons. The following patch will
> solve the problem. */ // original code //
> params.put(SVNFetchFactory.PROP_ELEMENTNAME, element); // begin of the
> patch
> if(org.osgi.framework.Version.emptyVersion.equals(entryInfos .get( "internal.matchedVersion")))
> { params.put(SVNFetchFactory.PROP_ELEMENTNAME, element); } else {
> params.put(SVNFetchFactory.PROP_ELEMENTNAME, element + "_"
> +entryInfos.get("internal.matchedVersion")); } // end of the patch
> params.put(SVNFetchFactory.PROP_FILETOCHECK, locationToCheck.toString());
> params.put(SVNFetchFactory.PROP_DESTINATIONFOLDER,destinatio n.removeLastSegments(1).toString());
> params.put(SVNFetchFactory.PROP_URL,(String)entryInfos.get(S VNFetchFactory.KEY_URL));
> if (entryInfos.containsKey(SVNFetchFactory.KEY_PEG)) {
> params.put(SVNFetchFactory.PROP_PEG,(String)entryInfos.get(S VNFetchFactory.KEY_PEG));
> } else { params.put(SVNFetchFactory.PROP_PEG, "HEAD"); } if
> (entryInfos.containsKey(SVNFetchFactory.KEY_REVISION)) {
> params.put(SVNFetchFactory.PROP_REVISION,(String)entryInfos. get(SVNFetchFactory.KEY_REVISION));
> } else { params.put(SVNFetchFactory.PROP_REVISION, "HEAD"); }
> params.put(SVNFetchFactory.PROP_TAG, SVNFetchFactory.overrideTag);
> params.put(SVNFetchFactory.PROP_PATH,(String)entryInfos.get( SVNFetchFactory.KEY_PATH));
> String username = (String)entryInfos.get(SVNFetchFactory.KEY_USERNAME);
> params.put(SVNFetchFactory.PROP_USERNAME, username != null ? username
> :""); String password =
> (String)entryInfos.get(SVNFetchFactory.KEY_PASSWORD);
> params.put(SVNFetchFactory.PROP_PASSWORD, password != null ? password
> :"");
> this.printAvailableTask(locationToCheck.toString(),locationT oCheck.toString(),
> script); if (IFetchFactory.ELEMENT_TYPE_PLUGIN.equals(type)
> ||IFetchFactory.ELEMENT_TYPE_FRAGMENT.equals(type)) {
> this.printAvailableTask(locationToCheck.toString(),locationT oCheck.removeLastSegments(1).append(Constants.BUNDLE_FILENAM E_DESCRIPTOR).toString(),
> script); }
> script.printAntCallTask(SVNFetchFactory.TARGET_FETCH_FROM_SV N,
> true,params); } public void generateRetrieveFilesCall(Map entryInfos,
> IPath destination,String[] files, IAntScript script) { String rootUrl =
> (String)entryInfos.get(SVNFetchFactory.KEY_URL); String pegRev =
> (String)entryInfos.get(SVNFetchFactory.KEY_PEG); String rev =
> (String)entryInfos.get(SVNFetchFactory.KEY_REVISION); String tag =
> SVNFetchFactory.overrideTag; String path =
> (String)entryInfos.get(SVNFetchFactory.KEY_PATH); String baseUrl =
> rootUrl + "/" + tag + "/" + path + "/"; String dest =
> destination.toString(); String username =
> (String)entryInfos.get(SVNFetchFactory.KEY_USERNAME); String password =
> (String)entryInfos.get(SVNFetchFactory.KEY_PASSWORD); for (String
> fileName : files) { this.printSVNTask("cat", baseUrl + fileName, pegRev,
> rev, dest + "/" +fileName, username, password, script); } } /* * Map
> file entry format: * mapEntry * : elementType '@' elementID (','
> elementVersion)? = svnContent * ; * elementType * : 'bundle' |
> 'feature' | 'plugin' | 'fragment' * ; * elementID * : ... //plug-in,
> feature, fragment or bundle ID * ; * elementVersion * : ...
> //plug-in, feature, fragment or bundle version * ; * svnContent * :
> 'SVN' (',' arg)+ * ; * arg * : key '=' value * ; * key * : 'url'
> // project root URL * | 'tag' // optional tag name (trunk,
> tags/some_name etc.) * | 'path' // optional element, path relative to
> project root URL * | 'revision' // optional element, revision * |
> 'peg' // optional element, peg revision * | 'username' * | 'password'
> * ; */ public void parseMapFileEntry(String rawEntry, Properties
> overrideTags, MapentryInfos) throws CoreException { String []arguments =
> Utils.getArrayFromStringWithBlank(rawEntry,SVNFetchFactory.M AP_ENTRY_SEPARATOR);
> // check entry count here.... for (String argument : arguments) { int
> idx = argument.indexOf(SVNFetchFactory.VALUE_PAIR_SEPARATOR); if (idx
> != -1) { String key = argument.substring(0, idx); String value =
> argument.substring(idx + 1); entryInfos.put(key, value); } } if
> (overrideTags != null) { SVNFetchFactory.overrideTag
> =overrideTags.getProperty(SVNFetchFactory.OVERRIDE_TAG); if
> (SVNFetchFactory.overrideTag != null
> &&SVNFetchFactory.overrideTag.length() > 0) { StringTokenizer st = new
> StringTokenizer(SVNFetchFactory.overrideTag,"/"); String lastToken =
> null; while (st.hasMoreTokens() == true) { lastToken =
> st.nextToken(); } entryInfos.put(IFetchFactory.KEY_ELEMENT_TAG,
> lastToken); } } // handle optional path String path =
> (String)entryInfos.get(SVNFetchFactory.KEY_PATH); if (path == null) {
> entryInfos.put(SVNFetchFactory.KEY_PATH,entryInfos.get(IFetc hFactory.KEY_ELEMENT_NAME));
> } // handle optional tag String tag =
> (String)entryInfos.get(IFetchFactory.KEY_ELEMENT_TAG); if (tag == null)
> { entryInfos.put(IFetchFactory.KEY_ELEMENT_TAG, ""); } } protected void
> printSVNTask(String command, String url, String pegRev,String rev, String
> dest, String username, String password, IAntScriptscript) {
> script.printTabs(); script.print("<svn");
> script.printAttribute("command", command, false);
> script.printAttribute("url", url, false); script.printAttribute("pegRev",
> pegRev, false); script.printAttribute("rev", rev, false);
> script.printAttribute("dest", dest, false);
> script.printAttribute("username", username, false);
> script.printAttribute("password", password, false);
> script.println("/>"); } protected void printAvailableTask(String
> property, String file, IAntScriptscript) { script.printTabs();
> script.print("<available"); script.printAttribute("property", property,
> true); script.printAttribute("file", file, false);
> script.println("/>"); }}
>
Previous Topic:svn markers in the package explorer
Next Topic:Missing Jar Error
Goto Forum:
  


Current Time: Fri Apr 26 07:32:55 GMT 2024

Powered by FUDForum. Page generated in 0.02687 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top