Return-Path: X-Original-To: apmail-ant-notifications-archive@minotaur.apache.org Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 80A05DD3F for ; Wed, 29 Aug 2012 13:23:34 +0000 (UTC) Received: (qmail 34392 invoked by uid 500); 29 Aug 2012 13:23:34 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 34350 invoked by uid 500); 29 Aug 2012 13:23:34 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 34343 invoked by uid 99); 29 Aug 2012 13:23:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Aug 2012 13:23:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Aug 2012 13:23:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A07CE238897F for ; Wed, 29 Aug 2012 13:22:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1378533 [1/3] - in /ant/sandbox/antdsl/branches/import-experiment: ./ ant/ org.apache.ant.antdsl/ org.apache.ant.antdsl/.settings/ org.apache.ant.antdsl/META-INF/services/ org.apache.ant.antdsl/src/org/apache/ant/antdsl/ org.apache.ant.ant... Date: Wed, 29 Aug 2012 13:22:43 -0000 To: notifications@ant.apache.org From: hibou@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120829132244.A07CE238897F@eris.apache.org> Author: hibou Date: Wed Aug 29 13:22:42 2012 New Revision: 1378533 URL: http://svn.apache.org/viewvc?rev=1378533&view=rev Log: Add the possibility to make 'path' of build module and ant task being computed by Ivy Added: ant/sandbox/antdsl/branches/import-experiment/ant/ (with props) ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch ant/sandbox/antdsl/branches/import-experiment/org.apache.ant.antdsl/META-INF/services/org.apache.tools.ant.ArgumentProcessor ant/sandbox/antdsl/branches/import-experiment/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AntDSLArgProcessor.java (with props) ant/sandbox/antdsl/branches/import-experiment/test/ant/ (with props) ant/sandbox/antdsl/branches/import-experiment/test/ant/ivy-fixed.xml (with props) ant/sandbox/antdsl/branches/import-experiment/test/ant/ivy.xml (with props) ant/sandbox/antdsl/branches/import-experiment/test/ant/ivysettings.xml (with props) Modified: ant/sandbox/antdsl/branches/import-experiment/ (props changed) ant/sandbox/antdsl/branches/import-experiment/build.xml ant/sandbox/antdsl/branches/import-experiment/ivy-fixed.xml ant/sandbox/antdsl/branches/import-experiment/ivy.xml ant/sandbox/antdsl/branches/import-experiment/org.apache.ant.antdsl/.classpath ant/sandbox/antdsl/branches/import-experiment/org.apache.ant.antdsl/.settings/org.eclipse.jdt.core.prefs ant/sandbox/antdsl/branches/import-experiment/org.apache.ant.antdsl/META-INF/services/org.apache.tools.ant.ProjectHelper ant/sandbox/antdsl/branches/import-experiment/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java ant/sandbox/antdsl/branches/import-experiment/org.apache.ant.antdsl/src/org/apache/ant/antdsl/OSGiFrameworkManager.java ant/sandbox/antdsl/branches/import-experiment/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AntExpressionCondition.java ant/sandbox/antdsl/branches/import-experiment/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java ant/sandbox/antdsl/branches/import-experiment/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/ParserCreator.java ant/sandbox/antdsl/branches/import-experiment/test/ (props changed) ant/sandbox/antdsl/branches/import-experiment/test/build.ant ant/sandbox/antdsl/branches/import-experiment/test/build.xml ant/sandbox/antdsl/branches/import-experiment/test/test-module.bnd Propchange: ant/sandbox/antdsl/branches/import-experiment/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Aug 29 13:22:42 2012 @@ -2,4 +2,3 @@ build lib build-deps *.classpath -.ant Propchange: ant/sandbox/antdsl/branches/import-experiment/ant/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Wed Aug 29 13:22:42 2012 @@ -0,0 +1,2 @@ +felix-cache +ant.path Added: ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch?rev=1378533&view=auto ============================================================================== --- ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch (added) +++ ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch Wed Aug 29 13:22:42 2012 @@ -0,0 +1,433 @@ +Index: src/main/org/apache/tools/ant/ArgumentProcessor.java +=================================================================== +--- src/main/org/apache/tools/ant/ArgumentProcessor.java (revision 0) ++++ src/main/org/apache/tools/ant/ArgumentProcessor.java (working copy) +@@ -0,0 +1,80 @@ ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one or more ++ * contributor license agreements. See the NOTICE file distributed with ++ * this work for additional information regarding copyright ownership. ++ * The ASF licenses this file to You under the Apache License, Version 2.0 ++ * (the "License"); you may not use this file except in compliance with ++ * the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ * ++ */ ++package org.apache.tools.ant; ++ ++import java.util.List; ++ ++/** ++ * Processor of arguments of the command line. ++ *

++ * Arguments supported by third party code should not conflict with Ant core ++ * ones. It is then recommended to chose specific 'enough' argument name, ++ * avoiding for instance one letter arguments. By the way, if there any ++ * conflict, Ant will take precedence. ++ * ++ * @since 1.9 ++ */ ++public interface ArgumentProcessor { ++ ++ /** ++ * Check that the specified argument is handled. It returns 0 if not ++ * supported. Else it returns the number of expected arguments to read after ++ * the current one. ++ */ ++ int readArgument(String arg); ++ ++ /** ++ * If some arguments matched, this method is called after all arguments were ++ * parsed. Returns true if Ant should stop there, ie the build ++ * file not parsed and the project should not be executed. ++ *

++ * NB: the size of the argument list might not be the expected one if the ++ * end user doesn't have provided enough ones. ++ */ ++ boolean handleArg(List args); ++ ++ /** ++ * If some arguments matched, this method is called just before the project ++ * being configured ++ *

++ * NB: the size of the argument list might not be the expected one if the ++ * end user doesn't have provided enough ones. ++ */ ++ void prepareConfigure(Project project, List args); ++ ++ /** ++ * Handle the arguments, just after the project being configured. Returns ++ * true if Ant should stop there, ie the build file not parsed ++ * and the project should not be executed. ++ *

++ * NB: the size of the argument list might not be the expected one if the ++ * end user doesn't have provided enough ones. ++ */ ++ boolean handleArg(Project project, List arg); ++ ++ /** ++ * Print the usage of the supported arguments ++ * ++ * @param buffer the buffer to populate ++ * @param lSep the line separator to use ++ * ++ * @see org.apache.tools.ant.Main.printUsage() ++ */ ++ void printUsage(StringBuffer buffer, String lSep); ++ ++} + +Property changes on: src/main/org/apache/tools/ant/ArgumentProcessor.java +___________________________________________________________________ +Added: svn:mime-type +## -0,0 +1 ## ++text/plain +\ No newline at end of property +Added: svn:keywords +## -0,0 +1 ## ++Date Revision Author HeadURL Id +\ No newline at end of property +Added: svn:eol-style +## -0,0 +1 ## ++native +\ No newline at end of property +Index: src/main/org/apache/tools/ant/Main.java +=================================================================== +--- src/main/org/apache/tools/ant/Main.java (revision 1376402) ++++ src/main/org/apache/tools/ant/Main.java (working copy) +@@ -24,12 +24,14 @@ + import java.io.IOException; + import java.io.InputStream; + import java.io.PrintStream; ++import java.util.ArrayList; + import java.util.Arrays; + import java.util.Collections; + import java.util.Enumeration; + import java.util.HashMap; + import java.util.HashSet; + import java.util.Iterator; ++import java.util.List; + import java.util.Map; + import java.util.Map.Entry; + import java.util.Properties; +@@ -152,6 +154,7 @@ + */ + private boolean proxy = false; + ++ private Map, List> extraArguments = new HashMap, List>(); + + private static final GetProperty NOPROPERTIES = new GetProperty(){ + public Object getProperty(String aName) { +@@ -324,6 +327,8 @@ + boolean justPrintVersion = false; + boolean justPrintDiagnostics = false; + ++ ArgumentProcessorRegistry processorRegistry = ArgumentProcessorRegistry.getInstance(); ++ + for (int i = 0; i < args.length; i++) { + String arg = args[i]; + +@@ -399,11 +404,27 @@ + } else if (arg.equals("-autoproxy")) { + proxy = true; + } else if (arg.startsWith("-")) { +- // we don't have any more args to recognize! +- String msg = "Unknown argument: " + arg; +- System.err.println(msg); +- printUsage(); +- throw new BuildException(""); ++ boolean processed = false; ++ for (ArgumentProcessor processor : processorRegistry.getProcessors()) { ++ int n = processor.readArgument(arg); ++ if (n > 0) { ++ List extraArgs = new ArrayList(); ++ extraArgs.add(arg); ++ for (int j = 1; j < n && i < args.length - 1; j++) { ++ extraArgs.add(args[++i]); ++ } ++ extraArguments.put(processor.getClass(), extraArgs); ++ processed = true; ++ break; ++ } ++ } ++ if (!processed) { ++ // we don't have any more args to recognize! ++ String msg = "Unknown argument: " + arg; ++ System.err.println(msg); ++ printUsage(); ++ throw new BuildException(""); ++ } + } else { + // if it's no other arg, it may be the target + targets.addElement(arg); +@@ -726,6 +747,17 @@ + return; + } + ++ ArgumentProcessorRegistry processorRegistry = ArgumentProcessorRegistry.getInstance(); ++ ++ for (ArgumentProcessor processor : processorRegistry.getProcessors()) { ++ List extraArgs = extraArguments.get(processor.getClass()); ++ if (extraArgs != null) { ++ if (processor.handleArg(extraArgs)) { ++ return; ++ } ++ } ++ } ++ + final Project project = new Project(); + project.setCoreLoader(coreLoader); + +@@ -781,8 +813,24 @@ + proxySetup.enableProxies(); + } + ++ for (ArgumentProcessor processor : processorRegistry.getProcessors()) { ++ List extraArgs = extraArguments.get(processor.getClass()); ++ if (extraArgs != null) { ++ processor.prepareConfigure(project, extraArgs); ++ } ++ } ++ + ProjectHelper.configureProject(project, buildFile); + ++ for (ArgumentProcessor processor : processorRegistry.getProcessors()) { ++ List extraArgs = extraArguments.get(processor.getClass()); ++ if (extraArgs != null) { ++ if (processor.handleArg(project, extraArgs)) { ++ return; ++ } ++ } ++ } ++ + if (projectHelp) { + printDescription(project); + printTargets(project, msgOutputLevel > Project.MSG_INFO, +@@ -996,7 +1044,10 @@ + msg.append(" -noclasspath Run ant without using CLASSPATH" + lSep); + msg.append(" -autoproxy Java1.5+: use the OS proxy settings" + + lSep); +- msg.append(" -main override Ant's normal entry point"); ++ msg.append(" -main override Ant's normal entry point" + lSep); ++ for (ArgumentProcessor processor : ArgumentProcessorRegistry.getInstance().getProcessors()) { ++ processor.printUsage(msg, lSep); ++ } + System.out.println(msg.toString()); + } + +Index: src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java +=================================================================== +--- src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java (revision 0) ++++ src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java (working copy) +@@ -0,0 +1,189 @@ ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one or more ++ * contributor license agreements. See the NOTICE file distributed with ++ * this work for additional information regarding copyright ownership. ++ * The ASF licenses this file to You under the Apache License, Version 2.0 ++ * (the "License"); you may not use this file except in compliance with ++ * the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ * ++ */ ++package org.apache.tools.ant; ++ ++import java.io.BufferedReader; ++import java.io.IOException; ++import java.io.InputStream; ++import java.io.InputStreamReader; ++import java.net.URL; ++import java.util.ArrayList; ++import java.util.Enumeration; ++import java.util.List; ++ ++import org.apache.tools.ant.util.LoaderUtils; ++ ++/** ++ * The global registry for {@link ArgumentProcessor}s. ++ *

++ * An {@link ArgumentProcessor} implementation can be registered via the system ++ * property org.apache.tools.ant.ArgumentProcessor, or via a JDK1.3 ++ * 'service', by putting the fully qualified name of the implementation into the ++ * file META-INF/services/org.apache.tools.ant.ArgumentProcessor ++ *

++ * Use the system property ant.argument-processor.debug to enable ++ * the print of debug log. ++ * ++ * @since 1.9 ++ */ ++public class ArgumentProcessorRegistry { ++ ++ private static final String SYSTEM_PROPERTY = "org.apache.tools.ant.ArgumentProcessor"; ++ ++ private static final String DEBUG_ARGUMENT_PROCESSOR_REPOSITORY = "ant.argument-processor.debug"; ++ ++ // The message log level is not accessible here because everything ++ // is instanciated statically ++ private static final boolean DEBUG = "true".equals(System.getProperty(DEBUG_ARGUMENT_PROCESSOR_REPOSITORY)); ++ ++ private static final String SERVICE_ID = "META-INF/services/org.apache.tools.ant.ArgumentProcessor"; ++ ++ private static ArgumentProcessorRegistry instance = new ArgumentProcessorRegistry(); ++ ++ private List processors = new ArrayList(); ++ ++ public static ArgumentProcessorRegistry getInstance() { ++ return instance; ++ } ++ ++ private ArgumentProcessorRegistry() { ++ collectArgumentProcessors(); ++ } ++ ++ public List getProcessors() { ++ return processors; ++ } ++ ++ private void collectArgumentProcessors() { ++ ArgumentProcessor processor = getArgumentProcessorBySystemProperty(); ++ registerArgumentProcessor(processor); ++ try { ++ ClassLoader classLoader = LoaderUtils.getContextClassLoader(); ++ if (classLoader != null) { ++ Enumeration resources = classLoader.getResources(SERVICE_ID); ++ while (resources.hasMoreElements()) { ++ URL resource = resources.nextElement(); ++ processor = getProcessorByService(resource.openStream()); ++ registerArgumentProcessor(processor); ++ } ++ } ++ ++ InputStream systemResource = ClassLoader.getSystemResourceAsStream(SERVICE_ID); ++ if (systemResource != null) { ++ processor = getProcessorByService(systemResource); ++ registerArgumentProcessor(processor); ++ } ++ } catch (Exception e) { ++ System.err.println("Unable to load ArgumentProcessor from service " ++ + SERVICE_ID + " (" + e.getClass().getName() + ": " ++ + e.getMessage() + ")"); ++ if (DEBUG) { ++ e.printStackTrace(System.err); ++ } ++ } ++ } ++ ++ public void registerArgumentProcessor(String helperClassName) ++ throws BuildException { ++ registerArgumentProcessor(getProcessor(helperClassName)); ++ } ++ ++ public void registerArgumentProcessor( ++ Class< ? extends ArgumentProcessor> helperClass) ++ throws BuildException { ++ registerArgumentProcessor(getProcessor(helperClass)); ++ } ++ ++ private ArgumentProcessor getProcessor(String helperClassName) { ++ try { ++ @SuppressWarnings("unchecked") ++ Class< ? extends ArgumentProcessor> cl = (Class< ? extends ArgumentProcessor>) Class.forName(helperClassName); ++ return getProcessor(cl); ++ } catch (ClassNotFoundException e) { ++ throw new BuildException("Argument processor class " ++ + helperClassName + " was not found", e); ++ } ++ } ++ ++ private ArgumentProcessor getProcessor( ++ Class< ? extends ArgumentProcessor> processorClass) { ++ ArgumentProcessor processor; ++ try { ++ processor = processorClass.getConstructor().newInstance(); ++ } catch (Exception e) { ++ throw new BuildException("The argument processor class" ++ + processorClass.getClass().getName() ++ + " could not be instanciated with a default constructor", ++ e); ++ } ++ return processor; ++ } ++ ++ public void registerArgumentProcessor(ArgumentProcessor processor) { ++ if (processor == null) { ++ return; ++ } ++ processors.add(processor); ++ if (DEBUG) { ++ System.out.println("Argument processor " ++ + processor.getClass().getName() + " registered."); ++ } ++ } ++ ++ private ArgumentProcessor getArgumentProcessorBySystemProperty() { ++ String processorClass = System.getProperty(SYSTEM_PROPERTY); ++ try { ++ if (processorClass != null) { ++ return getProcessor(processorClass); ++ } ++ } catch (Exception e) { ++ System.err.println("Unable to load ArgumentProcessor class \"" ++ + processorClass + " specified in system property " ++ + SYSTEM_PROPERTY + " (" + e.getMessage() + ")"); ++ if (DEBUG) { ++ e.printStackTrace(System.err); ++ } ++ } ++ return null; ++ } ++ ++ private ArgumentProcessor getProcessorByService(InputStream is) ++ throws IOException { ++ InputStreamReader isr = null; ++ try { ++ try { ++ isr = new InputStreamReader(is, "UTF-8"); ++ } catch (java.io.UnsupportedEncodingException e) { ++ isr = new InputStreamReader(is); ++ } ++ BufferedReader rd = new BufferedReader(isr); ++ String processorClassName = rd.readLine(); ++ if (processorClassName != null && !"".equals(processorClassName)) { ++ return getProcessor(processorClassName); ++ } ++ } finally { ++ try { ++ isr.close(); ++ } catch (IOException e) { ++ // ignore ++ } ++ } ++ return null; ++ } ++ ++} + +Property changes on: src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java +___________________________________________________________________ +Added: svn:mime-type +## -0,0 +1 ## ++text/plain +\ No newline at end of property +Added: svn:keywords +## -0,0 +1 ## ++Date Revision Author HeadURL Id +\ No newline at end of property +Added: svn:eol-style +## -0,0 +1 ## ++native +\ No newline at end of property Modified: ant/sandbox/antdsl/branches/import-experiment/build.xml URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/branches/import-experiment/build.xml?rev=1378533&r1=1378532&r2=1378533&view=diff ============================================================================== --- ant/sandbox/antdsl/branches/import-experiment/build.xml (original) +++ ant/sandbox/antdsl/branches/import-experiment/build.xml Wed Aug 29 13:22:42 2012 @@ -1,13 +1,12 @@ - - - + + @@ -17,7 +16,8 @@ - + + @@ -34,7 +34,7 @@ - + @@ -44,22 +44,31 @@ + - + + + + + + + - + + + @@ -99,9 +108,9 @@ - + - + @@ -145,6 +154,15 @@ + + + + + + + + +