From easyant-commits-return-17-apmail-incubator-easyant-commits-archive=incubator.apache.org@incubator.apache.org Thu Feb 17 17:03:21 2011 Return-Path: Delivered-To: apmail-incubator-easyant-commits-archive@minotaur.apache.org Received: (qmail 62807 invoked from network); 17 Feb 2011 17:03:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Feb 2011 17:03:21 -0000 Received: (qmail 14451 invoked by uid 500); 17 Feb 2011 17:03:21 -0000 Delivered-To: apmail-incubator-easyant-commits-archive@incubator.apache.org Received: (qmail 14420 invoked by uid 500); 17 Feb 2011 17:03:21 -0000 Mailing-List: contact easyant-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: easyant-dev@incubator.apache.org Delivered-To: mailing list easyant-commits@incubator.apache.org Received: (qmail 14406 invoked by uid 99); 17 Feb 2011 17:03:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Feb 2011 17:03:20 +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; Thu, 17 Feb 2011 17:03:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 585622388C56; Thu, 17 Feb 2011 17:02:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1071697 [18/42] - in /incubator/easyant: buildtypes/ buildtypes/trunk/ buildtypes/trunk/build-osgi-bundle-java/ buildtypes/trunk/build-osgi-bundle-java/src/ buildtypes/trunk/build-osgi-bundle-java/src/main/ buildtypes/trunk/build-osgi-bund... Date: Thu, 17 Feb 2011 17:01:56 -0000 To: easyant-commits@incubator.apache.org From: hibou@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110217170209.585622388C56@eris.apache.org> Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/Phase.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/Phase.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/Phase.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/Phase.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,53 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.ant; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.RuntimeConfigurable; +import org.apache.tools.ant.Target; +import org.apache.tools.ant.Task; + + +/** + * A special kind of target that must be empty. + * + * @since Ant 1.8.0 + */ +public class Phase extends Target { + + // no "clone" constructor since I'm not really sure where it is + // used + + private static final String NO_CHILDREN_ALLOWED + = "you must not nest child elements into a phase"; + + /** + * Throws an exception. + */ + public final void addTask(Task task) { + throw new BuildException(NO_CHILDREN_ALLOWED); + } + + /** + * Throws an exception. + */ + public final void addDataType(RuntimeConfigurable r) { + throw new BuildException(NO_CHILDREN_ALLOWED); + } +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/Phase.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/Phase.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/Phase.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/DefaultEasyAntLogger.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/DefaultEasyAntLogger.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/DefaultEasyAntLogger.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/DefaultEasyAntLogger.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,154 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.ant.listerners; + +import org.apache.tools.ant.BuildEvent; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DefaultLogger; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.ProjectHelper; +import org.apache.tools.ant.util.StringUtils; + +public class DefaultEasyAntLogger extends DefaultLogger { + + private static final String WHERE_MSG = "* Where"; + private static final String DIAGNOSTIC_MSG = "* Dr Myrmex diagnostic"; + private static final String RECOMENDATION_MSG = "* Recomendation ..."; + private static final String RECOMENDATION_LONG_DESC = "Dr Myrmex suggest you to run easyant with -verbose or -debug option to get more details."; + + private long startTime = System.currentTimeMillis(); + + protected static void throwableMessage(StringBuffer m, Throwable error, + boolean verbose) { + + while (error !=null) { + Throwable cause = error.getCause(); + if (cause == null) { + break; + } + String msg1 = error.toString(); + String msg2 = cause.toString(); + if (msg1.endsWith(msg2)) { + String messageException = msg1.substring(0, msg1.length() + - msg2.length()); + if (error instanceof BuildException) { + BuildException be = (BuildException) error; + + // wipe location information + if (be.getLocation() != null) { + messageException = messageException.substring(be + .getLocation().toString().length()); + + } + } + m.append("Error : ").append(messageException); + m.append(lSep); + m.append("Cause : "); + error = cause; + } else { + break; + } + } + // if (verbose || !(error instanceof BuildException)) { + if (verbose) { + m.append(StringUtils.getStackTrace(error)); + } else { + m.append(error.getMessage()).append(lSep); + } + } + + @Override + public void buildFinished(BuildEvent event) { + Throwable error = event.getException(); + StringBuffer message = new StringBuffer(); + if (error == null) { + message.append(StringUtils.LINE_SEP); + message.append(getBuildSuccessfulMessage()); + } else { + message.append(StringUtils.LINE_SEP); + message.append(getBuildFailedMessage()); + message.append(StringUtils.LINE_SEP); + + message.append("Dr Myrmex found an error when building "); + message.append(extractProjectName(event)); + message.append(StringUtils.LINE_SEP); + if (error instanceof BuildException) { + BuildException be = (BuildException) error; + if (be.getLocation().getFileName() != null) { + message.append(WHERE_MSG); + message.append(lSep).append(lSep); + message.append("File : ").append( + be.getLocation().getFileName()).append(lSep); + message.append("Line : ").append( + be.getLocation().getLineNumber()); + message.append(" column : ").append( + be.getLocation().getColumnNumber()).append(lSep); + } + if (Project.MSG_DEBUG == msgOutputLevel) { + message.append(StringUtils.LINE_SEP); + message.append("Import stack :"); + message.append(StringUtils.LINE_SEP); + ProjectHelper helper = (ProjectHelper) event + .getProject() + .getReference(ProjectHelper.PROJECTHELPER_REFERENCE); + for (int i = 0; i < helper.getImportStack().size(); i++) { + message.append(helper.getImportStack().get(i) + .toString()); + message.append(StringUtils.LINE_SEP); + + } + } + + } + message.append(StringUtils.LINE_SEP); + message.append(DIAGNOSTIC_MSG); + message.append(StringUtils.LINE_SEP); + message.append(StringUtils.LINE_SEP); + throwableMessage(message, error, + Project.MSG_VERBOSE <= msgOutputLevel); + message.append(StringUtils.LINE_SEP); + if (msgOutputLevel < Project.MSG_VERBOSE) { + message.append(StringUtils.LINE_SEP); + message.append(RECOMENDATION_MSG); + message.append(StringUtils.LINE_SEP); + message.append(StringUtils.LINE_SEP); + message.append(RECOMENDATION_LONG_DESC); + } + } + message.append(StringUtils.LINE_SEP); + message.append(StringUtils.LINE_SEP); + message.append("Total time: "); + message.append(formatTime(System.currentTimeMillis() - startTime)); + + String msg = message.toString(); + if (error == null) { + printMessage(msg, out, Project.MSG_VERBOSE); + } else { + printMessage(msg, err, Project.MSG_ERR); + } + log(msg); + + } + + @Override + public void buildStarted(BuildEvent event) { + startTime = System.currentTimeMillis(); + } + +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/DefaultEasyAntLogger.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/DefaultEasyAntLogger.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/DefaultEasyAntLogger.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/MultiModuleLogger.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/MultiModuleLogger.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/MultiModuleLogger.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/MultiModuleLogger.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,218 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.ant.listerners; + +import java.io.File; + +import org.apache.tools.ant.BuildEvent; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.listener.TimestampedLogger; +import org.apache.tools.ant.util.StringUtils; + +public class MultiModuleLogger extends DefaultEasyAntLogger { + + private volatile boolean subBuildStartedRaised = false; + private final Object subBuildLock = new Object(); + + // CheckStyle:VisibilityModifier OFF - bc + /** + * Name of the current target, if it should be displayed on the next + * message. This is set when a target starts building, and reset to + * null after the first message for the target is logged. + */ + protected String targetName; + // CheckStyle:VisibilityModifier ON + + /** + * Header string for the log. * {@value} + */ + public static final String HEADER = "======================================================================"; + /** + * Footer string for the log. * {@value} + */ + public static final String FOOTER = HEADER; + + /** + * This is an override point: the message that indicates whether a build + * failed. Subclasses can change/enhance the message. + * + * @return The classic "BUILD FAILED" plus a timestamp + */ + protected String getBuildFailedMessage() { + return super.getBuildFailedMessage() + TimestampedLogger.SPACER + + getTimestamp(); + } + + /** + * This is an override point: the message that indicates that a build + * succeeded. Subclasses can change/enhance the message. + * + * @return The classic "BUILD SUCCESSFUL" plus a timestamp + */ + protected String getBuildSuccessfulMessage() { + return super.getBuildSuccessfulMessage() + TimestampedLogger.SPACER + + getTimestamp(); + } + + /** + * {@inheritDoc} + * + * @param event + */ + public void targetStarted(BuildEvent event) { + maybeRaiseSubBuildStarted(event); + targetName = extractTargetName(event); + } + + /** + * {@inheritDoc} + * + * @param event + */ + public void taskStarted(BuildEvent event) { + maybeRaiseSubBuildStarted(event); + super.taskStarted(event); + } + + /** + * {@inheritDoc} + * + * @param event + */ + public void buildFinished(BuildEvent event) { + maybeRaiseSubBuildStarted(event); + subBuildFinished(event); + super.buildFinished(event); + } + + /** + * {@inheritDoc} + * + * @param event + */ + public void messageLogged(BuildEvent event) { + maybeRaiseSubBuildStarted(event); + super.messageLogged(event); + if (event.getPriority() > msgOutputLevel || null == event.getMessage() + || "".equals(event.getMessage().trim())) { + return; + } + + synchronized (this) { + if (null != targetName) { + out.println(StringUtils.LINE_SEP + targetName + ":"); + targetName = null; + } + } + + } + + /** + * {@inheritDoc} + * + * @param event + * An event with any relevant extra information. Must not be + * null. + */ + public void subBuildStarted(BuildEvent event) { + String name = extractNameOrDefault(event); + Project project = event.getProject(); + + File base = project == null ? null : project.getBaseDir(); + String path = (base == null) ? "With no base directory" : "In " + + base.getAbsolutePath(); + printMessage(StringUtils.LINE_SEP + getHeader() + StringUtils.LINE_SEP + + "Entering project " + name + StringUtils.LINE_SEP + path + + StringUtils.LINE_SEP + getFooter(), out, event.getPriority()); + } + + /** + * Get the name of an event + * + * @param event + * the event name + * @return the name or a default string + */ + protected String extractNameOrDefault(BuildEvent event) { + String name = extractProjectName(event); + if (name == null) { + name = ""; + } else { + name = '"' + name + '"'; + } + return name; + } + + /** {@inheritDoc} */ + public void subBuildFinished(BuildEvent event) { + String name = extractNameOrDefault(event); + String failed = event.getException() != null ? "failing " : ""; + printMessage(StringUtils.LINE_SEP + getHeader() + StringUtils.LINE_SEP + + "Exiting " + failed + "project " + name + + StringUtils.LINE_SEP + getFooter(), out, event.getPriority()); + } + + /** + * Override point: return the header string for the entry/exit message + * + * @return the header string + */ + protected String getHeader() { + return HEADER; + } + + /** + * Override point: return the footer string for the entry/exit message + * + * @return the footer string + */ + protected String getFooter() { + return FOOTER; + } + + private void maybeRaiseSubBuildStarted(BuildEvent event) { + // double checked locking should be OK since the flag is write-once + if (!subBuildStartedRaised) { + synchronized (subBuildLock) { + if (!subBuildStartedRaised) { + subBuildStartedRaised = true; + subBuildStarted(event); + } + } + } + } + + /** + * Override point, extract the target name + * + * @param event + * the event to work on + * @return the target name -including the owning project name (if non-null) + */ + protected String extractTargetName(BuildEvent event) { + String targetName = event.getTarget().getName(); + String projectName = extractProjectName(event); + if (projectName != null && targetName != null) { + return projectName + '.' + targetName; + } else { + return targetName; + } + } + +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/MultiModuleLogger.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/MultiModuleLogger.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/MultiModuleLogger.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/AdvancedInheritableItem.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/AdvancedInheritableItem.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/AdvancedInheritableItem.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/AdvancedInheritableItem.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,56 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.descriptor; + +import org.apache.easyant.core.ivy.InheritableScope; +import org.apache.ivy.core.module.descriptor.InheritableItem; + +/** + * Interface for elements that can be inherited from a parent descriptor by a child descriptor + * This interface provides some useful methods to have fine grain control on inheritable elements + * @author neoverflow + * + */ +public interface AdvancedInheritableItem extends InheritableItem { + + /** + * Get the current inherit scope + * @return the inherit scope + */ + public InheritableScope getInheritScope(); + + /** + * Set inherit scope + * @param inheritScope an inherit scope + */ + public void setInheritScope(InheritableScope inheritScope); + + /** + * Check if element can be inherited + * @return true if element can be inherited + */ + public boolean isInheritable(); + + /** + * Specify if an element can be inherited or not + * @param isIneritable true if element can be inherited + */ + public void setInheritable(boolean isIneritable); + +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/AdvancedInheritableItem.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/AdvancedInheritableItem.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/AdvancedInheritableItem.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/DefaultEasyAntDescriptor.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/DefaultEasyAntDescriptor.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/DefaultEasyAntDescriptor.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/DefaultEasyAntDescriptor.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,130 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ + +package org.apache.easyant.core.descriptor; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.ivy.core.module.descriptor.ModuleDescriptor; + +/** + * This class is the default implementation of EasyAnt ModuleDescriptor + */ +public class DefaultEasyAntDescriptor implements EasyAntModuleDescriptor { + + public DefaultEasyAntDescriptor() { + // super(md); + properties = new HashMap(); + plugins = new ArrayList(); + buildConfigurations = new ArrayList(); + phaseMappings = new ArrayList(); + } + + private ModuleDescriptor ivyModuleDescriptor; + private String buildType; + private Map properties; + private List plugins; + private List buildConfigurations; + + private List phaseMappings; + + public String getBuildType() { + return buildType; + } + + public Map getProperties() { + return properties; + } + + public void setBuildType(String buildType) { + this.buildType = buildType; + + } + + public void setProperties(Map properties) { + this.properties = properties; + + } + + public void addPlugin(String pluginModule, String as, boolean mandatory) { + addPlugin(pluginModule, as, mandatory, "include"); + } + + public void addPlugin(String pluginModule, String as, boolean mandatory, String mode) { + PluginDescriptor plugin = new PluginDescriptor(); + plugin.setModule(pluginModule); + plugin.setAs(as); + + plugin.setMandatory(mandatory); + if (mode != null) { + plugin.setMode(mode); + } else plugin.setMode("include"); + this.plugins.add(plugin); + } + + public void addPlugin(PluginDescriptor pluginDescriptor) { + if (pluginDescriptor == null) { + throw new IllegalArgumentException("pluginDescriptor argument can't be null"); + } + this.plugins.add(pluginDescriptor); + } + + + public List getPlugins() { + return plugins; + } + + public void addBuildConfiguration(String value) { + this.buildConfigurations.add(value); + } + + public List getBuildConfigurations() { + return buildConfigurations; + } + + public void setIvyModuleDescriptor(ModuleDescriptor ivyModuleDescriptor) { + this.ivyModuleDescriptor = ivyModuleDescriptor; + } + + public ModuleDescriptor getIvyModuleDescriptor() { + return this.ivyModuleDescriptor; + } + + public String getName() { + return getIvyModuleDescriptor().getModuleRevisionId().getName(); + } + + public String getDescription() { + return getIvyModuleDescriptor().getDescription(); + } + + public List getPhaseMappings() { + return phaseMappings; + } + + public void addPhaseMapping(PhaseMappingDescriptor phaseMappingDescriptor) { + this.phaseMappings.add(phaseMappingDescriptor); + } + + + +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/DefaultEasyAntDescriptor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/DefaultEasyAntDescriptor.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/DefaultEasyAntDescriptor.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/EasyAntModuleDescriptor.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/EasyAntModuleDescriptor.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/EasyAntModuleDescriptor.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/EasyAntModuleDescriptor.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,150 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ + +package org.apache.easyant.core.descriptor; + +import java.util.List; +import java.util.Map; + +import org.apache.ivy.core.module.descriptor.ModuleDescriptor; + +/** + * This interface is used to access to all metadata provided in <easyant> + * tag in a module descriptor + */ +public interface EasyAntModuleDescriptor { + + /** + * Get the corresponding ivy module descriptor + * + * @return the ivy module Descriptor + */ + ModuleDescriptor getIvyModuleDescriptor(); + + /** + * Get all the properties loaded inside the <easyant> tag. + * + * @return a map of properties + */ + Map getProperties(); + + /** + * Get the build type defined in the module descriptor + * + * @return a string that represent the build type module revision id + * (example org.apache.easyant#build-std-java;0.1) + */ + String getBuildType(); + + /** + * Set the build type that should be used + * + * @param buildType + * a string that represent the build type module revision id + * (example org.apache.easyant#build-std-java;0.1) + */ + void setBuildType(String buildType); + + /** + * Get all plugins defined in the module descriptor + * + * @return a list of module revision id that references plugins + */ + List getPlugins(); + + /** + * Add a plugin to the easyant context (considered as include) + * + * @param pluginModule + * a string that represents a module revision id + * @param as + * a string that represents an alias + * @param mandatory + * is this plugin mandatory? + * @deprecated since 0.6 + */ + void addPlugin(String pluginModule, String as, boolean mandatory); + + /** + * Add a plugin to the easyant context and define if we should include or + * import it + * + * @param pluginModule + * a string that represents a module revision id + * @param as + * a string that represents an alias + * @param mandatory + * is this plugin mandatory? + * @param mode + * a string that represents the import mode (include / import) + * @deprecated since 0.6 + */ + void addPlugin(String pluginModule, String as, boolean mandatory, + String mode); + + /** + * Add a plugin to the easyant context + * + * @param pluginDescriptor + * a plugindescriptor + */ + void addPlugin(PluginDescriptor pluginDescriptor); + + /** + * Add a build configuration to the easyant context + * + * @param value + * a string that represents a build configuration name + */ + void addBuildConfiguration(String value); + + /** + * Return a list of build configuration defined in this context + * + * @return a list of string that contains build configuration names + */ + List getBuildConfigurations(); + + /** + * Return the module name + * + * @return a string representing the module name + */ + String getName(); + + /** + * Return the module description + * + * @return a string representing the module description + */ + String getDescription(); + + /** + * Get all registered phase mappings + * @return a list of {@link PhaseMappingDescriptor} + */ + public List getPhaseMappings(); + + /** + * Add a {@link PhaseMappingDescriptor} to the list of all registered phase mappings + * @param phaseMappingDescriptor a {@link PhaseMappingDescriptor} + */ + public void addPhaseMapping(PhaseMappingDescriptor phaseMappingDescriptor); + +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/EasyAntModuleDescriptor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/EasyAntModuleDescriptor.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/EasyAntModuleDescriptor.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PhaseMappingDescriptor.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PhaseMappingDescriptor.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PhaseMappingDescriptor.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PhaseMappingDescriptor.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,60 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.descriptor; + +public class PhaseMappingDescriptor { + + private String target; + private String toPhase; + private String buildConfigurations; + public String getTarget() { + return target; + } + public void setTarget(String target) { + this.target = target; + } + + public String getToPhase() { + return toPhase; + } + + public void setToPhase(String toPhase) { + this.toPhase = toPhase; + } + + /** + * Return a build configuration name bound to this plugin + * @return a build configuration name + */ + public String getBuildConfigurations() { + return buildConfigurations; + } + + /** + * set a build configuration name bound to this plugin + * @param buildConfigurationName a build configuration name + */ + public void setBuildConfigurations(String buildConfigurations) { + this.buildConfigurations = buildConfigurations; + } + + + + +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PhaseMappingDescriptor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PhaseMappingDescriptor.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PhaseMappingDescriptor.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PluginDescriptor.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PluginDescriptor.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PluginDescriptor.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PluginDescriptor.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,229 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ + +package org.apache.easyant.core.descriptor; + +import org.apache.easyant.core.ivy.InheritableScope; +import org.apache.ivy.core.module.id.ModuleRevisionId; + +/** + * This class is a simple POJO used to store informations on a plugin. + * + */ +public class PluginDescriptor implements AdvancedInheritableItem { + private String organisation; + private String module; + private String revision; + + private String mrid; + + private String mode; + private String as; + + private boolean mandatory; + private String buildConfigurations; + private InheritableScope inheritScope = InheritableScope.BOTH; + + private final ModuleRevisionId sourceModule; + private boolean inheritable=true; + + /** + * Default constructor + */ + public PluginDescriptor() { + sourceModule=null; + } + + /** + * Constructor specifying the source module which was defining the plugin + * @param sourceModule a source module + */ + public PluginDescriptor(ModuleRevisionId sourceModule) { + this.sourceModule=sourceModule; + } + + /** + * Get the plugin name + * + * @return the plugin name + */ + public String getModule() { + return module; + } + + /** + * Set the plugin name + * + * @param module + * the plugin name to set + */ + public void setModule(String module) { + this.module = module; + } + + + /** + * Get the organisation of the module to import + * + * @return the organisation name + */ + public String getOrganisation() { + return organisation; + } + + /** + * Set the organisation of the module to import + * + * @param organisation + * the organisation name + */ + public void setOrganisation(String organisation) { + this.organisation = organisation; + } + + /** + * Get the revision of the module to import + * + * @return the revision + */ + public String getRevision() { + return revision; + } + + /** + * Set th revision of the module to import + * + * @param revision + * the revision + */ + public void setRevision(String revision) { + this.revision = revision; + } + + /** + * Get the full mrid of the module to import + * + * @return the mrid to import + */ + public String getMrid() { + return mrid != null ? mrid : ModuleRevisionId.newInstance(organisation, module, revision).toString(); + } + + /** + * Set the full mrid of the module to import + * + * @param mrid + * the mrdi to import + */ + public void setMrid(String mrid) { + this.mrid = mrid; + } + + + /** + * Get the import mode of a plugin + * + * @return a string that represent the import mode (import / include) + */ + public String getMode() { + return mode; + } + + /** + * Set the import mode of a plugin + * @param mode a string that represent the import mode (import / include) + */ + public void setMode(String mode) { + this.mode = mode; + } + + /** + * Get the alias name + * @return the alias name + */ + public String getAs() { + return as; + } + + /** + * Set the alias name + * @param as the alias name + */ + public void setAs(String as) { + this.as = as; + } + + /** + * is this plugin mandatory? + * @return true if the plugin is mandatory, false if the plugin can be skipped + */ + public boolean isMandatory() { + return mandatory; + } + + /** + * is this plugin mandatory? + * @param mandatory true if the plugin is mandatory, false if the plugin can be skipped + */ + public void setMandatory(boolean mandatory) { + this.mandatory = mandatory; + } + + /** + * set a build configuration name bound to this plugin + * @param buildConfigurationName a build configuration name + */ + public void setBuildConfigurations(String buildConfigurationName) { + this.buildConfigurations = buildConfigurationName; + } + + /** + * Return a build configuration name bound to this plugin + * @return a build configuration name + */ + public String getBuildConfigurations() { + return buildConfigurations; + } + + /** + * {@inheritDoc} + */ + public ModuleRevisionId getSourceModule() { + return sourceModule; + } + + public InheritableScope getInheritScope() { + return inheritScope; + } + + public void setInheritScope(InheritableScope inheritScope) { + this.inheritScope = inheritScope; + } + + public boolean isInheritable() { + return inheritable; + } + + public void setInheritable(boolean isIneritable) { + this.inheritable=isIneritable; + + } + + +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PluginDescriptor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PluginDescriptor.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PluginDescriptor.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PropertyDescriptor.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PropertyDescriptor.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PropertyDescriptor.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PropertyDescriptor.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,109 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.descriptor; + +import org.apache.easyant.core.ivy.InheritableScope; +import org.apache.ivy.core.module.id.ModuleRevisionId; + +public class PropertyDescriptor implements AdvancedInheritableItem { + private final String name; + private String description; + private String defaultValue; + private String value; + private boolean required; + private String buildConfigurations; + private final ModuleRevisionId sourceModule; + private InheritableScope inheritScope; + private boolean inheritable=true; + + public PropertyDescriptor(String propertyName) { + this.name = propertyName; + this.sourceModule = null; + } + + public PropertyDescriptor(String propertyName, ModuleRevisionId sourceModule) { + this.name = propertyName; + this.sourceModule = sourceModule; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public boolean isRequired() { + return required; + } + + public void setRequired(boolean required) { + this.required = required; + } + + public String getBuildConfigurations() { + return buildConfigurations; + } + + public void setBuildConfigurations(String buildConfiguration) { + this.buildConfigurations = buildConfiguration; + } + + public ModuleRevisionId getSourceModule() { + return sourceModule; + } + + public InheritableScope getInheritScope() { + return inheritScope; + } + + public void setInheritScope(InheritableScope inheritScope) { + this.inheritScope = inheritScope; + } + + public boolean isInheritable() { + return inheritable; + } + + public void setInheritable(boolean isIneritable) { + this.inheritable=isIneritable; + + } +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PropertyDescriptor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PropertyDescriptor.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/descriptor/PropertyDescriptor.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/factory/EasyantConfigurationFactory.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/factory/EasyantConfigurationFactory.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/factory/EasyantConfigurationFactory.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/factory/EasyantConfigurationFactory.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,60 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.factory; + +import java.net.URL; + +import org.apache.easyant.core.EasyAntConfiguration; +import org.apache.easyant.core.parser.EasyAntConfigParser; + +public class EasyantConfigurationFactory { + + private static EasyantConfigurationFactory instance; + private EasyAntConfigParser parser; + + protected EasyantConfigurationFactory() { + parser = new EasyAntConfigParser(); + } + + public static EasyantConfigurationFactory getInstance() { + if (instance == null) { + instance = new EasyantConfigurationFactory(); + } + return instance; + } + + public EasyAntConfiguration createDefaultConfiguration() { + return new EasyAntConfiguration(); + } + + public EasyAntConfiguration createConfigurationFromFile( + final EasyAntConfiguration easyAntConfiguration, + URL configUrl) throws Exception { + + return parser.parseAndMerge(configUrl,easyAntConfiguration); + } + + public EasyAntConfiguration createConfigurationFromFile( + URL configurationFile) throws Exception { + EasyAntConfiguration easyAntConfiguration = createDefaultConfiguration(); + return createConfigurationFromFile(easyAntConfiguration, + configurationFile); + } + +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/factory/EasyantConfigurationFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/factory/EasyantConfigurationFactory.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/factory/EasyantConfigurationFactory.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/InheritableScope.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/InheritableScope.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/InheritableScope.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/InheritableScope.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,23 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.ivy; + +public enum InheritableScope { + CHILD,BOTH +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/InheritableScope.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/InheritableScope.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/InheritableScope.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/IvyInstanceHelper.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/IvyInstanceHelper.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/IvyInstanceHelper.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/IvyInstanceHelper.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,107 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.ivy; + +import org.apache.easyant.core.EasyAntMagicNames; +import org.apache.ivy.ant.IvyAntSettings; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.types.Reference; + +/** + * Helper providing methods to play with both project and easyant ivy instances + * + */ +public class IvyInstanceHelper { + + + /** + * Get the project ivy instance name. This methods takes in consideration that project ivy instance name can be set through "project.ivy.instance" property + * @param project a project instance + * @return the project ivy instance name + */ + public static String getProjectIvyInstanceName(Project project) { + String projectIvyInstanceProp = project.getProperty(EasyAntMagicNames.PROJECT_IVY_INSTANCE); + if (projectIvyInstanceProp == null) { + projectIvyInstanceProp = EasyAntMagicNames.PROJECT_IVY_INSTANCE; + } + return projectIvyInstanceProp; + } + + /** + * Build a project ivy reference. + * @param project a project instance + * @return a project ivy refrence + */ + public static Reference buildProjectIvyReference(Project project) { + return buildIvyReference(project,getProjectIvyInstanceName(project)); + } + + /** + * Build an easyant ivy reference + * @param project a project instance + * @return an easyant ivy reference + */ + public static Reference buildEasyAntIvyReference(Project project) { + return buildIvyReference(project,EasyAntMagicNames.EASYANT_IVY_INSTANCE); + } + + /** + * Build an ivy instance reference based on a given instance name + * @param project a project instance + * @param instanceName an instance name + * @return an ivy instance reference + */ + public static Reference buildIvyReference (Project project,String instanceName) { + return new Reference(project, instanceName); + } + + /** + * Get project {@link IvyAntSettings} + * @param project a project instance + * @return the project {@link IvyAntSettings} + */ + public static IvyAntSettings getProjectIvyAntSettings(Project project) { + return getIvyAntSettings(project, getProjectIvyInstanceName(project)); + } + + /** + * Get easyant {@link IvyAntSettings} + * @param project a project instance + * @return the easyant {@link IvyAntSettings} + */ + public static IvyAntSettings getEasyAntIvyAntSettings(Project project) { + return getIvyAntSettings(project, EasyAntMagicNames.EASYANT_IVY_INSTANCE); + } + + /** + * Get an {@link IvyAntSettings} based on instance name + * @param project a project instance + * @param instanceName an {@link IvyAntSettings} name + * @return the requested {@link IvyAntSettings} + */ + public static IvyAntSettings getIvyAntSettings(Project project, String instanceName) { + Object o = project.getReference(instanceName); + if (o != null && o instanceof IvyAntSettings) { + return (IvyAntSettings)o; + } else { + throw new IllegalStateException(instanceName + " is not a valid ivy instance"); + } + } + +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/IvyInstanceHelper.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/IvyInstanceHelper.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/IvyInstanceHelper.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/repository/JarRepository.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/repository/JarRepository.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/repository/JarRepository.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/repository/JarRepository.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,157 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.ivy.repository; + +import java.io.File; +import java.io.IOException; +import java.net.JarURLConnection; +import java.net.URL; +import java.util.*; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.ivy.plugins.repository.url.URLRepository; + +/** + * JarRepository extends the default URLRepository provided by ivy but introduce a + * way to list files/directories inside a jar. + */ +public class JarRepository extends URLRepository { + + private static final Pattern URL_PATTERN = Pattern.compile("([^!]+)!/(.*)"); + private static final Directory emptyNode = new Directory(); + + /** lazily cache jar file directories to speed up repository searches and reporting */ + private HashMap jarCache = new HashMap(); + + public List list(String parent) throws IOException { + if (parent.startsWith("jar")) { + //extract path in parent + Matcher matcher = URL_PATTERN.matcher(parent); + matcher.find(); + + String baseUrl = matcher.group(1); + String path = matcher.group(2); + + //find the parent path in the directory. + Directory directory = getDirectory(baseUrl, parent).findEntry(path); + return new ArrayList(directory.getChildren()); + } + return super.list(parent); + } + + @Override + public void put(File source, String destination, boolean overwrite) throws IOException { + super.put(source, destination, overwrite); + //purge directory cache + flush(destination); + } + + /** + * get a sorted list of entries in the given jar file + * @param baseName the base URL of the jar file + * @param jarUrl complete URL to the entry being searched + */ + private Directory getDirectory(String baseName, String jarUrl) throws IOException { + synchronized (jarCache) { + Directory cached = jarCache.get(baseName); + if (cached == null) { + URL url = new URL(jarUrl); + JarURLConnection conn = (JarURLConnection) url.openConnection(); + JarFile file = conn.getJarFile(); + if (file == null) { + return emptyNode; + } else { + cached = new Directory(); + for (Enumeration entries = file.entries(); entries.hasMoreElements(); ) { + JarEntry entry = entries.nextElement(); + cached.addEntry(entry.getName()); + } + jarCache.put(baseName, cached); + } + } + return cached; + } + } + + /** flush the cached directory for the given jar file */ + private void flush(String jarUrl) throws IOException { + jarUrl = getBaseUrl(jarUrl); + synchronized (jarCache) { + jarCache.remove(jarUrl); + } + } + + /** retrieve the part of jarUrl that refers to the jar file, stripping any specific entry from the end */ + private String getBaseUrl(String jarUrl) { + int separator = jarUrl.indexOf('!'); + if (separator > 0) { + jarUrl = jarUrl.substring(0, separator); + } + return jarUrl; + } + + /** a logical directory in a Jar file */ + private static class Directory { + + private HashMap children = new HashMap(); + + public Set getChildren() { + return children.keySet(); + } + + /** + * Create subdirectory entries for the path name rooted + * at this directory. + */ + public void addEntry(String name) { + String[] path = name.split("/"); + Directory entry = this; + for (int i = 0; i < path.length; ++i) { + String childName = path[i]; + if (childName.length() > 0) { + Directory child = entry.children.get(childName); + if (child == null) { + entry.children.put(childName, child = new Directory()); + } + entry = child; + } + } + } + + /** + * Find the subdirectory named path rooted + * at this directory. + */ + public Directory findEntry(String name) { + String[] path = name.split("/"); + Directory entry = this; + for (int i = 0; entry != null && i < path.length; ++i) { + String childName = path[i]; + if (childName.length() > 0) { + entry = entry.children.get(childName); + } + } + return entry == null ? emptyNode : entry; + } + + } +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/repository/JarRepository.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/repository/JarRepository.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/repository/JarRepository.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/resolvers/JarResolver.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/resolvers/JarResolver.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/resolvers/JarResolver.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/resolvers/JarResolver.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,36 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.ivy.resolvers; + +import org.apache.easyant.core.ivy.repository.JarRepository; +import org.apache.ivy.plugins.resolver.URLResolver; + +/** + * JarResolver extends the default URLResolver provided by ivy but introduce a + * way to list files/directories inside a jar. + */ +public class JarResolver extends URLResolver { + public JarResolver() { + setRepository(new JarRepository()); + } + + public String getTypeName() { + return "jar"; + } +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/resolvers/JarResolver.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/resolvers/JarResolver.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ivy/resolvers/JarResolver.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGenerator.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGenerator.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGenerator.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGenerator.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,67 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.menu; + +import java.io.IOException; + + +/** + * Common interface for menu generators. The recursive parameter M + * is used to support building nested menus. For example, the typical class + * declaration for a MenuGenerator will look like + *
+ * public class MyMenuGenerator implements MenuGenerator<MyMenuGenerator> { ... }
+ * 
+ * @param the concrete menu type implemented by this generator, to be + * passed when creating nested menus as in {@link #addSubMenu}. + */ +public interface MenuGenerator> { + + /** + * Create a new menu with the given title and location on disk. + * @param title the text that should be displayed for the menu title. + * @param location the location on disk where the menu text should be stored. may be ignored by some implementations for submenus. + * @throws IOException if there is an error creating the menu + */ + public void startMenu(String title, String location) throws IOException; + + /** + * Add an entry to the menu. + * @param title the title to appear on the menu entry + * @param targetLink the target for the menu entry, e.g. a URL or file path + * @throws IOException if there are errors adding a new entry to the menu. + */ + public void addEntry(String title, String targetLink) throws IOException; + + /** + * Add a submenu entry to the menu. It is not the responsibility + * of the parent menu to call {@link #startMenu(String, String)} on the provided child + * menu. + * + * @param title the title in the parent menu. + * @param subMenu the submenu + * @throws IOException if there are errors adding a link to the submenu + */ + public void addSubMenu(String title, M subMenu) throws IOException; + + /** + * Finish writing the menu + */ + public void endMenu() throws IOException; +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGenerator.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGenerator.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGenerator.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGeneratorRegistry.java URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGeneratorRegistry.java?rev=1071697&view=auto ============================================================================== --- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGeneratorRegistry.java (added) +++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGeneratorRegistry.java Thu Feb 17 17:01:07 2011 @@ -0,0 +1,96 @@ +/* + * Copyright 2008-2010 the EasyAnt project + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * 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. + */ +package org.apache.easyant.core.menu; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * A registry holding a list of {@link MenuGenerator} related to a given context + * + */ +public class MenuGeneratorRegistry { + private List menuGenerators = new ArrayList(); + private final String context; + + /** + * Default constructor + * @param context the related context + */ + public MenuGeneratorRegistry(String context) { + this.context = context; + } + + + /** + * Get a list of registred {@link MenuGenerator}s + * @return a list of registred {@link MenuGenerator} + */ + public List getMenuGenerators() { + return menuGenerators; + } + + /** + * Add a given {@link MenuGenerator} + * @param menuGenerator a given {@link MenuGenerator} + * @return true the element was added + */ + public boolean addMenuGenerator(MenuGenerator menuGenerator) { + return menuGenerators.add(menuGenerator); + } + + /** + * Remove a given {@link MenuGenerator} + * @param menuGenerator a given {@link MenuGenerator} + * @return true if the element was removed + */ + public boolean removeMenuGenerator(MenuGenerator menuGenerator) { + return menuGenerators.remove(menuGenerator); + } + + /** + * Propagate the generation to all registered {@link MenuGenerator} + * {@inheritDoc} + */ + public void addEntry(String title, String targetLink) throws IOException { + for (MenuGenerator menuGenerator : menuGenerators) { + menuGenerator.addEntry(title, targetLink); + } + } + + /** + * Call {@link org.apache.easyant.core.menu.MenuGenerator#endMenu()} on all registered + * menu generators. + */ + public void endMenu() throws IOException { + for (MenuGenerator menuGenerator : menuGenerators) { + menuGenerator.endMenu(); + } + } + + /** + * Get the context related to this registry + * @return a string representing the context + */ + public String getContext() { + return context; + } + +} Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGeneratorRegistry.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGeneratorRegistry.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Author HeadURL Id Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/menu/MenuGeneratorRegistry.java ------------------------------------------------------------------------------ svn:mime-type = text/plain