[jboss-cvs] JBossAS SVN: r84871 - in projects/ejb3/trunk/ivy: src/main and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 27 08:59:01 EST 2009
Author: wolfc
Date: 2009-02-27 08:59:01 -0500 (Fri, 27 Feb 2009)
New Revision: 84871
Added:
projects/ejb3/trunk/ivy/src/main/ant/
projects/ejb3/trunk/ivy/src/main/ant/maven-ant-tasks.xml
projects/ejb3/trunk/ivy/src/main/ant/xpath-task.xml
projects/ejb3/trunk/ivy/src/main/java/org/jboss/ejb3/ivy/ant/
projects/ejb3/trunk/ivy/src/main/java/org/jboss/ejb3/ivy/ant/GeneratePom.java
projects/ejb3/trunk/ivy/src/main/java/org/jboss/ejb3/ivy/ant/XPathTask.java
projects/ejb3/trunk/ivy/src/test/java/org/jboss/ejb3/ivy/ant/
projects/ejb3/trunk/ivy/src/test/java/org/jboss/ejb3/ivy/ant/XPathTaskTestCase.java
Modified:
projects/ejb3/trunk/ivy/
projects/ejb3/trunk/ivy/build.xml
projects/ejb3/trunk/ivy/ivy.xml
Log:
EJBTHREE-1744: deploy a stable snapshot to snapshots.jboss.org
Property changes on: projects/ejb3/trunk/ivy
___________________________________________________________________
Name: svn:ignore
- eclipse-target
+ eclipse-target
distrib
target
Modified: projects/ejb3/trunk/ivy/build.xml
===================================================================
--- projects/ejb3/trunk/ivy/build.xml 2009-02-27 11:54:29 UTC (rev 84870)
+++ projects/ejb3/trunk/ivy/build.xml 2009-02-27 13:59:01 UTC (rev 84871)
@@ -1,33 +1,116 @@
<!--
vi:ts=3:sw=3:expandtab:
-->
-<project name="jboss-ejb3-ivy" xmlns:ivy="antlib:org.apache.ivy.ant"
+<project name="jboss-ejb3-ivy"
+ xmlns:ivy="antlib:org.apache.ivy.ant"
+ xmlns:maven="urn:maven-artifact-ant"
default="package">
+
+ <!-- Setup Ivy -->
<path id="ivy.lib.path">
<fileset dir="/opt/apache-ivy" includes="*.jar"/>
+ <pathelement path="target/classes"/>
</path>
- <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
+ <!-- Because we're hacking our own task, we must share class loaders -->
+ <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" loaderref="ivy.lib.path.loader"/>
+ <!-- Load settings -->
<ivy:settings file="src/main/ivy/ivysettings.xml"/>
+ <import file="src/main/ant/maven-ant-tasks.xml"/>
+ <import file="src/main/ant/xpath-task.xml"/>
+
+ <!-- The current version -->
+ <property name="module.version.target" value="1.0"/>
+
+ <target name="clean-build" description="clean the project build files">
+ <delete includeemptydirs="true" dir="target"/>
+ </target>
+
<target name="compile" depends="resolve">
<ivy:cachepath pathid="compile.classpath" conf="compile"/>
<mkdir dir="target/classes"/>
<javac srcdir="src/main/java" destdir="target/classes" classpathref="compile.classpath"/>
</target>
+
+ <!-- normally don't depend on xpath, it should be defined already -->
+ <target name="deploy" depends="package,makepom,define-xpath">
+ <xpath file="${user.home}/.m2/settings.xml" expression="/settings/servers/server[id='snapshots.jboss.org']/username" property="dav.username"/>
+ <xpath file="${user.home}/.m2/settings.xml" expression="/settings/servers/server[id='snapshots.jboss.org']/password" property="dav.password"/>
+ <maven:deploy file="target/jboss-ejb3-ivy.jar">
+ <pom file="target/pom.xml"/>
+ <!-- TODO: refid="snapshots.jboss.org" -->
+ <remoteRepository url="dav:https://snapshots.jboss.org/maven2">
+ <authentication username="${dav.username}" password="${dav.password}"/>
+ </remoteRepository>
+ </maven:deploy>
+ </target>
+
+ <!-- Normally depends on resolve, but we're doing ourselves -->
+ <target name="generatepom" depends="resolve">
+ <!--
+ <taskdef name="generatepom" classname="org.jboss.ejb3.ivy.ant.GeneratePom" classpathref="ivy.lib.path" loaderref="ivy.lib.path.loader"/>
+ <generatepom pomFile="target/pom.xml"/>
+ -->
+ <ivy:deliver/>
+ </target>
- <target name="package" depends="compile">
+ <target name="ivy-new-version" unless="ivy.new.revision">
+ <property name="module.version.prefix" value="${module.version.target}-dev-"/>
+ <ivy:info/>
+ <ivy:buildnumber organisation="${ivy.organisation}" module="${ivy.module}" revision="${module.version.prefix}" defaultBuildNumber="1" revSep=""/>
+ </target>
+
+ <target name="local-version">
+ <tstamp>
+ <format property="now" pattern="yyyyMMddHHmmss" timezone="UTC"/>
+ </tstamp>
+ <property name="ivy.new.revision" value="${module.version.target}-${now}-local"/>
+ </target>
+
+ <target name="makepom" depends="resolve,local-version">
+ <!-- note that we use module.version.target and not version -->
+ <ivy:deliver
+ deliverpattern="${ivy.distrib.dir}/[type]s/[artifact].[ext]"
+ pubdate="${now}"
+ pubrevision="${module.version.target}-SNAPSHOT"
+ status="integration"/>
+ <ivy:makepom
+ ivyfile="${ivy.distrib.dir}/ivys/ivy.xml"
+ pomfile="target/pom.xml">
+ <mapping conf="compile" scope="compile"/>
+ </ivy:makepom>
+ </target>
+
+ <target name="package" depends="version,compile"
+ description="package the output directory into a jar file">
<jar destfile="target/jboss-ejb3-ivy.jar">
<fileset dir="target/classes"/>
</jar>
</target>
+ <target name="publish" depends="clean-build,package"
+ description="publish this project in the shared ivy repository">
+ <ivy:publish resolver="shared" pubrevision="${version}" status="milestone">
+ <artifacts pattern="target/[artifact].[ext]"/>
+ </ivy:publish>
+ </target>
+
+ <target name="publish-local" depends="local-version,package"
+ description="publish this project in the local ivy repository">
+ <ivy:publish resolver="local" pubrevision="${version}" pubdate="${now}"
+ status="integration" forcedeliver="true">
+ <artifacts pattern="target/[artifact].[ext]"/>
+ </ivy:publish>
+ </target>
+
<target name="resolve">
<ivy:resolve/>
</target>
- <target name="test" depends="test-compile">
+ <target name="test" depends="test-compile"
+ description="execute all tests">
<mkdir dir="target/reports"/>
<junit printsummary="true">
<classpath>
@@ -49,4 +132,10 @@
<mkdir dir="target/test-classes"/>
<javac srcdir="src/test/java" destdir="target/test-classes" classpathref="test.classpath"/>
</target>
+
+ <target name="version" depends="ivy-new-version">
+ <mkdir dir="target/ivy"/>
+ <echo message="version=${ivy.new.revision}" file="target/ivy/${ant.project.name}.properties" append="false"/>
+ <property file="target/ivy/${ant.project.name}.properties"/>
+ </target>
</project>
Modified: projects/ejb3/trunk/ivy/ivy.xml
===================================================================
--- projects/ejb3/trunk/ivy/ivy.xml 2009-02-27 11:54:29 UTC (rev 84870)
+++ projects/ejb3/trunk/ivy/ivy.xml 2009-02-27 13:59:01 UTC (rev 84871)
@@ -3,13 +3,13 @@
-->
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
- <info organisation="org.jboss.ejb3" module="jboss-ejb3-ivy"/>
+ <info organisation="org.jboss.ejb3" module="jboss-ejb3-ivy" status="integration"/>
<configurations>
<conf name="compile"/>
<conf name="test" extends="compile" visibility="private"/>
</configurations>
<dependencies>
- <dependency org="org.apache.ivy" name="ivy" rev="2.0.0" conf="compile->default"/>
+ <dependency org="org.apache.ivy" name="ivy" rev="latest.release" conf="compile->default,optional,sources"/>
<dependency org="junit" name="junit" rev="4.4" conf="test->default"/>
</dependencies>
</ivy-module>
Added: projects/ejb3/trunk/ivy/src/main/ant/maven-ant-tasks.xml
===================================================================
--- projects/ejb3/trunk/ivy/src/main/ant/maven-ant-tasks.xml (rev 0)
+++ projects/ejb3/trunk/ivy/src/main/ant/maven-ant-tasks.xml 2009-02-27 13:59:01 UTC (rev 84871)
@@ -0,0 +1,31 @@
+<!--
+ vi:ts=3:sw=3:expandtab:
+-->
+<project xmlns:maven="urn:maven-artifact-ant"
+ xmlns:ivy="antlib:org.apache.ivy.ant">
+ <ivy:cachepath
+ pathid="maven-ant-tasks.classpath"
+ organisation="org.apache.maven"
+ module="maven-ant-tasks"
+ revision="2.0.9"
+ inline="true"
+ conf="default"/>
+ <ivy:cachepath
+ pathid="maven-wagon-webdav.classpath"
+ organisation="org.apache.maven.wagon"
+ module="wagon-webdav"
+ revision="1.0-beta-2"
+ inline="true"
+ conf="default"/>
+ <path id="maven-ant-full.classpath">
+ <path refid="maven-ant-tasks.classpath"/>
+ <path refid="maven-wagon-webdav.classpath"/>
+ </path>
+ <typedef
+ classpathref="maven-ant-full.classpath"
+ uri="urn:maven-artifact-ant"
+ resource="org/apache/maven/artifact/ant/antlib.xml"/>
+
+ <maven:remoteRepository id="snapshots.jboss.org" url="dav:https://snapshots.jboss.org/maven2">
+ </maven:remoteRepository>
+</project>
Added: projects/ejb3/trunk/ivy/src/main/ant/xpath-task.xml
===================================================================
--- projects/ejb3/trunk/ivy/src/main/ant/xpath-task.xml (rev 0)
+++ projects/ejb3/trunk/ivy/src/main/ant/xpath-task.xml 2009-02-27 13:59:01 UTC (rev 84871)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <!-- since we are the xpath task, it must come in over a target -->
+ <target name="define-xpath" depends="compile">
+ <taskdef name="xpath" classname="org.jboss.ejb3.ivy.ant.XPathTask" classpath="target/classes"/>
+ </target>
+</project>
\ No newline at end of file
Added: projects/ejb3/trunk/ivy/src/main/java/org/jboss/ejb3/ivy/ant/GeneratePom.java
===================================================================
--- projects/ejb3/trunk/ivy/src/main/java/org/jboss/ejb3/ivy/ant/GeneratePom.java (rev 0)
+++ projects/ejb3/trunk/ivy/src/main/java/org/jboss/ejb3/ivy/ant/GeneratePom.java 2009-02-27 13:59:01 UTC (rev 84871)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.ivy.ant;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.ivy.ant.IvyPostResolveTask;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorWriter;
+import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorWriter.ConfigurationScopeMapping;
+import org.apache.ivy.util.FileUtil;
+import org.apache.tools.ant.BuildException;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class GeneratePom extends IvyPostResolveTask
+{
+ public static class Mapping
+ {
+ private String conf;
+
+ private String scope;
+
+ public String getConf()
+ {
+ return conf;
+ }
+
+ public void setConf(String conf)
+ {
+ this.conf = conf;
+ }
+
+ public String getScope()
+ {
+ return scope;
+ }
+
+ public void setScope(String scope)
+ {
+ this.scope = scope;
+ }
+ }
+
+ private File headerFile;
+
+ private Collection<Mapping> mappings = new ArrayList<Mapping>();
+
+ private File pomFile;
+
+ public Mapping createMapping()
+ {
+ Mapping mapping = new Mapping();
+ this.mappings.add(mapping);
+ return mapping;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ivy.ant.IvyMakePom#doExecute()
+ */
+ @Override
+ public void doExecute() throws BuildException
+ {
+ prepareAndCheck();
+
+ // getResolveId() == null
+ ModuleId mid = getResolvedModuleId();
+ ModuleDescriptor md = (ModuleDescriptor) getResolvedDescriptor(mid.getOrganisation(), mid.getName());
+ try
+ {
+ PomModuleDescriptorWriter.write(md,
+ headerFile == null ? null : FileUtil.readEntirely(headerFile),
+ mappings.isEmpty()
+ ? PomModuleDescriptorWriter.DEFAULT_MAPPING
+ : new ConfigurationScopeMapping(getMappingsMap()), pomFile);
+ }
+ catch(IOException e)
+ {
+ throw new BuildException(e);
+ }
+ }
+
+ protected Map<String, String> getMappingsMap() {
+ Map<String, String> mappingsMap = new HashMap<String, String>();
+ for (Iterator<Mapping> iter = mappings.iterator(); iter.hasNext();) {
+ Mapping mapping = iter.next();
+ mappingsMap.put(mapping.getConf(), mapping.getScope());
+ }
+ return mappingsMap;
+ }
+
+ public void setHeaderFile(File headerFile)
+ {
+ this.headerFile = headerFile;
+ }
+
+ public void setPomFile(File pomFile)
+ {
+ this.pomFile = pomFile;
+ }
+}
Added: projects/ejb3/trunk/ivy/src/main/java/org/jboss/ejb3/ivy/ant/XPathTask.java
===================================================================
--- projects/ejb3/trunk/ivy/src/main/java/org/jboss/ejb3/ivy/ant/XPathTask.java (rev 0)
+++ projects/ejb3/trunk/ivy/src/main/java/org/jboss/ejb3/ivy/ant/XPathTask.java 2009-02-27 13:59:01 UTC (rev 84871)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.ivy.ant;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.xml.sax.InputSource;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class XPathTask extends Task
+{
+ private String expression;
+ private File file;
+ private String property;
+
+ @Override
+ public void execute() throws BuildException
+ {
+ XPath xpath = XPathFactory.newInstance().newXPath();
+ try
+ {
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ try
+ {
+ InputSource source = new InputSource(reader);
+ String value = xpath.evaluate(expression, source);
+ getProject().setNewProperty(property, value);
+ }
+ finally
+ {
+ reader.close();
+ }
+ }
+ catch(IOException e)
+ {
+ throw new BuildException(e);
+ }
+ catch (XPathExpressionException e)
+ {
+ throw new BuildException(e);
+ }
+ }
+
+ public void setExpression(String expression)
+ {
+ this.expression = expression;
+ }
+
+ public void setFile(File file)
+ {
+ this.file = file;
+ }
+
+ public void setProperty(String property)
+ {
+ this.property = property;
+ }
+}
Added: projects/ejb3/trunk/ivy/src/test/java/org/jboss/ejb3/ivy/ant/XPathTaskTestCase.java
===================================================================
--- projects/ejb3/trunk/ivy/src/test/java/org/jboss/ejb3/ivy/ant/XPathTaskTestCase.java (rev 0)
+++ projects/ejb3/trunk/ivy/src/test/java/org/jboss/ejb3/ivy/ant/XPathTaskTestCase.java 2009-02-27 13:59:01 UTC (rev 84871)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.ivy.ant;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+
+import org.apache.tools.ant.Project;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class XPathTaskTestCase
+{
+ @Test
+ public void test1() throws Exception
+ {
+ File file = new File(System.getProperty("user.home") + "/.m2/settings.xml");
+
+ String expression = "/settings/servers/server[id='snapshots.jboss.org']/username";
+
+ Project project = new Project();
+
+ XPathTask task = new XPathTask();
+ task.setFile(file);
+ task.setExpression(expression);
+ task.setProperty("test");
+ task.setProject(project);
+ task.execute();
+
+ String value = project.getProperty("test");
+ assertNotNull(value);
+ }
+}
More information about the jboss-cvs-commits
mailing list