Author: bodewig
Date: Thu Oct 30 04:48:04 2008
New Revision: 709148
URL: http://svn.apache.org/viewvc?rev=709148&view=rev
Log:
some initial code
Added:
ant/sandbox/javafront/NOTICE (with props)
ant/sandbox/javafront/build.xml (with props)
ant/sandbox/javafront/src/
ant/sandbox/javafront/src/etc/
ant/sandbox/javafront/src/etc/examples/
ant/sandbox/javafront/src/etc/examples/Simple.java (with props)
ant/sandbox/javafront/src/etc/examples/Simple2.java (with props)
ant/sandbox/javafront/src/etc/examples/Simple3.java (with props)
ant/sandbox/javafront/src/main/
ant/sandbox/javafront/src/main/org/
ant/sandbox/javafront/src/main/org/apache/
ant/sandbox/javafront/src/main/org/apache/ant/
ant/sandbox/javafront/src/main/org/apache/ant/javafront/
ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/
ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntProject.java
(with props)
ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntTarget.java
(with props)
ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/
ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/JavaFrontHelper.java
(with props)
ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/Target.java
(with props)
ant/sandbox/javafront/version.properties (with props)
Modified:
ant/sandbox/javafront/ (props changed)
Propchange: ant/sandbox/javafront/
------------------------------------------------------------------------------
--- svn:externals (added)
+++ svn:externals Thu Oct 30 04:48:04 2008
@@ -0,0 +1 @@
+common http://svn.apache.org/repos/asf/ant/antlibs/common/trunk
Added: ant/sandbox/javafront/NOTICE
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/NOTICE?rev=709148&view=auto
==============================================================================
--- ant/sandbox/javafront/NOTICE (added)
+++ ant/sandbox/javafront/NOTICE Thu Oct 30 04:48:04 2008
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0 ==
+ =========================================================================
+
+ Apache Ant JavaFront
+ Copyright 2008 The Apache Software Foundation
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
Propchange: ant/sandbox/javafront/NOTICE
------------------------------------------------------------------------------
svn:eol-style = native
Added: ant/sandbox/javafront/build.xml
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/build.xml?rev=709148&view=auto
==============================================================================
--- ant/sandbox/javafront/build.xml (added)
+++ ant/sandbox/javafront/build.xml Thu Oct 30 04:48:04 2008
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<project default="compile" name="javafront">
+
+ <!-- easy way to override properties -->
+ <property file="build.properties"/>
+
+ <!-- Java5 required -->
+ <property name="javac.-source" value="5"/>
+ <property name="javac.-target" value="5"/>
+
+ <!-- don't fork junit; regexp classes not available -->
+ <property name="junit.fork" value="false" />
+
+ <import file="common/build.xml"/>
+
+ <!-- ad-hoc override to plug in services description -->
+ <target name="antlib" depends="compile, check-for-NOTICE">
+ <copy todir="${build.classes}">
+ <fileset dir="src/main" includes="**/*.xml,**/*.properties"/>
+ </copy>
+ <jar destfile="${jarname}">
+ <fileset dir="${build.classes}"/>
+ <metainf file="NOTICE"/>
+ <metainf file="common/LICENSE"/>
+ <service type="org.apache.tools.ant.ProjectHelper"
+ provider="org.apache.ant.javafront.helper.JavaFrontHelper"/>
+ </jar>
+ </target>
+</project>
Propchange: ant/sandbox/javafront/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: ant/sandbox/javafront/src/etc/examples/Simple.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/etc/examples/Simple.java?rev=709148&view=auto
==============================================================================
--- ant/sandbox/javafront/src/etc/examples/Simple.java (added)
+++ ant/sandbox/javafront/src/etc/examples/Simple.java Thu Oct 30 04:48:04 2008
@@ -0,0 +1,27 @@
+/*
+ * 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.example;
+
+import org.apache.ant.javafront.annotations.AntTarget;
+
+public class Simple {
+ @AntTarget
+ public void sayHello() {
+ System.err.println("Hello, world!");
+ }
+}
Propchange: ant/sandbox/javafront/src/etc/examples/Simple.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ant/sandbox/javafront/src/etc/examples/Simple2.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/etc/examples/Simple2.java?rev=709148&view=auto
==============================================================================
--- ant/sandbox/javafront/src/etc/examples/Simple2.java (added)
+++ ant/sandbox/javafront/src/etc/examples/Simple2.java Thu Oct 30 04:48:04 2008
@@ -0,0 +1,40 @@
+/*
+ * 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.example;
+
+import org.apache.ant.javafront.annotations.AntProject;
+import org.apache.ant.javafront.annotations.AntTarget;
+
+import org.apache.tools.ant.Project;
+
[EMAIL PROTECTED]()
+public class Simple2 {
+ private final Project p;
+
+ public Simple2(Project p) {
+ this.p = p;
+ }
+
+ @AntTarget(Name="hello", Description="says hello", Depends="nonsense")
+ public void foo() {
+ p.log("Hello, world!");
+ p.log("This is " + p.getProperty("ant.version") + " calling.");
+ }
+
+ @AntTarget public void nonsense() {}
+}
Propchange: ant/sandbox/javafront/src/etc/examples/Simple2.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ant/sandbox/javafront/src/etc/examples/Simple3.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/etc/examples/Simple3.java?rev=709148&view=auto
==============================================================================
--- ant/sandbox/javafront/src/etc/examples/Simple3.java (added)
+++ ant/sandbox/javafront/src/etc/examples/Simple3.java Thu Oct 30 04:48:04 2008
@@ -0,0 +1,30 @@
+/*
+ * 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.example;
+
+import org.apache.ant.javafront.annotations.AntProject;
+import org.apache.tools.ant.Project;
+
[EMAIL PROTECTED](Name="simple3", BaseDir="..")
+public class Simple3 {
+ private Project p;
+
+ public void setProject(Project p) {
+ this.p = p;
+ }
+}
Propchange: ant/sandbox/javafront/src/etc/examples/Simple3.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntProject.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntProject.java?rev=709148&view=auto
==============================================================================
---
ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntProject.java
(added)
+++
ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntProject.java
Thu Oct 30 04:48:04 2008
@@ -0,0 +1,34 @@
+/*
+ * 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.ant.javafront.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation used to set project attributes.
+ */
[EMAIL PROTECTED](RetentionPolicy.RUNTIME)
[EMAIL PROTECTED](ElementType.TYPE)
+public @interface AntProject {
+ String Name() default "";
+ String DefaultTarget() default "";
+ String BaseDir() default ".";
+}
Propchange:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntProject.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntTarget.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntTarget.java?rev=709148&view=auto
==============================================================================
---
ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntTarget.java
(added)
+++
ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntTarget.java
Thu Oct 30 04:48:04 2008
@@ -0,0 +1,36 @@
+/*
+ * 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.ant.javafront.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation used to set project attributes.
+ */
[EMAIL PROTECTED](RetentionPolicy.RUNTIME)
[EMAIL PROTECTED](ElementType.METHOD)
+public @interface AntTarget {
+ String Name() default "";
+ String Depends() default "";
+ String If() default "";
+ String Unless() default "";
+ String Description() default "";
+}
Propchange:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/annotations/AntTarget.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/JavaFrontHelper.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/JavaFrontHelper.java?rev=709148&view=auto
==============================================================================
---
ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/JavaFrontHelper.java
(added)
+++
ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/JavaFrontHelper.java
Thu Oct 30 04:48:04 2008
@@ -0,0 +1,265 @@
+/*
+ * 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.ant.javafront.helper;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.ant.javafront.annotations.AntProject;
+import org.apache.ant.javafront.annotations.AntTarget;
+
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.taskdefs.Javac;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.util.FileUtils;
+
+/**
+ * Projecthelper that compiles the "build file", loads it,
+ * instantiates it and creates targets from the annotated methods.
+ */
+public class JavaFrontHelper extends ProjectHelper {
+
+ private static final File BUILD_FILE_DIR =
+ new File(new File(System.getProperty("java.io.tmpdir")), "javafront");
+
+ private static final Pattern PACKAGE_NAME =
+ Pattern.compile(".*?package\\s+(\\S+)\\s*;.*", Pattern.DOTALL);
+ private static final Pattern CLASS_NAME =
+ Pattern.compile(".*?class\\s+(\\S+)\\s.*", Pattern.DOTALL);
+
+ @Override
+ public void parse(Project project, Object source) throws BuildException {
+ if (source instanceof File) {
+ File buildFile = (File) source;
+ try {
+ String className = preParse(buildFile);
+ compile(project, buildFile, className);
+ Object o = createInstance(project, className);
+ populateProject(project, o, buildFile);
+ createTargets(project, o);
+ } catch (IOException e) {
+ throw new BuildException("failed to parse " + source, e);
+ }
+ } else {
+ throw new BuildException("Don't know how to parse "
+ + source.getClass());
+ }
+ }
+
+ /**
+ * Tries to determine the class's fully qualified name
+ */
+ private String preParse(File buildFile) throws IOException {
+ FileReader r = null;
+ String sourceText = "";
+ try {
+ r = new FileReader(buildFile);
+ sourceText = FileUtils.readFully(r);
+ } finally {
+ FileUtils.close(r);
+ }
+ String packageName = "";
+ Matcher m = PACKAGE_NAME.matcher(sourceText);
+ if (m.matches()) {
+ // not the anonymous package
+ packageName = m.group(1);
+ }
+ m = CLASS_NAME.matcher(sourceText);
+ if (!m.matches()) {
+ throw new BuildException("Can't find class name in " + buildFile
+ + " is it a Java source file?");
+ }
+ String className = m.group(1);
+ return packageName + (packageName.length() > 0 ? "." : "") + className;
+ }
+
+ /**
+ * Copies build file to temporary directory and compiles it.
+ */
+ private void compile(Project p, File buildFile, String className)
+ throws IOException {
+ File targetFile = new File(BUILD_FILE_DIR,
+ className.replace('.', File.separatorChar)
+ + ".java");
+ File parentDir = targetFile.getParentFile();
+ if (!parentDir.exists() && !parentDir.mkdirs()) {
+ throw new BuildException("failed to create " + parentDir);
+ }
+ FileUtils.getFileUtils().copyFile(buildFile, targetFile);
+ Javac javac = new Javac();
+ javac.setProject(p);
+ javac.setSrcdir(new Path(p, BUILD_FILE_DIR.getAbsolutePath()));
+ javac.setDestdir(BUILD_FILE_DIR);
+ javac.execute();
+ }
+
+ /**
+ * Loads the given class and tries to instantiate it, setting the
+ * project as constructor argument or via a setProject method if
+ * present.
+ */
+ private Object createInstance(Project p, String className) {
+ AntClassLoader loader =
+ new AntClassLoader(p,
+ new Path(p, BUILD_FILE_DIR.getAbsolutePath()));
+ Class clazz = null;
+ try {
+ clazz = loader.loadClass(className);
+ } catch (ClassNotFoundException e) {
+ throw new BuildException("failed to load " + className, e);
+ }
+
+ // try a public constructor with a Project arg first
+ try {
+ Constructor con = clazz.getConstructor(Project.class);
+ return con.newInstance(p);
+ } catch (SecurityException e) {
+ throw new BuildException("failed to reflect on " + className, e);
+ } catch (InstantiationException e) {
+ throw new BuildException(className + " seems to be abstract", e);
+ } catch (IllegalAccessException e) {
+ throw new BuildException("failed to invoke Project-constructor in "
+ + className, e);
+ } catch (IllegalArgumentException e) {
+ throw new BuildException("failed to invoke Project-constructor in "
+ + className, e);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() instanceof BuildException) {
+ throw (BuildException) e.getCause();
+ }
+ throw new BuildException("failed to invoke Project-constructor in "
+ + className, e);
+ } catch (NoSuchMethodException e) {
+ // No problem, fall back to no-arg constructor
+ }
+
+ Object o = null;
+ // next is a the no-arg constructor
+ try {
+ o = clazz.newInstance();
+ } catch (InstantiationException e) {
+ throw new BuildException(className + " seems to be abstract", e);
+ } catch (SecurityException e) {
+ throw new BuildException("failed to reflect on " + className, e);
+ } catch (IllegalAccessException e) {
+ throw new BuildException("failed to invoke no-arg constructor in "
+ + className, e);
+ } catch (IllegalArgumentException e) {
+ throw new BuildException("failed to invoke no-arg constructor in "
+ + className, e);
+ }
+
+ // look for a public * setProject(Project) method
+ try {
+ Method setProject = clazz.getMethod("setProject", Project.class);
+ setProject.invoke(o, p);
+ } catch (SecurityException e) {
+ throw new BuildException("failed to reflect on " + className, e);
+ } catch (IllegalAccessException e) {
+ throw new BuildException("failed to invoke setProject in "
+ + className, e);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() instanceof BuildException) {
+ throw (BuildException) e.getCause();
+ }
+ throw new BuildException("failed to invoke setProject in "
+ + className, e);
+ } catch (NoSuchMethodException e) {
+ // No problem, we just asked
+ }
+ return o;
+ }
+
+ /**
+ * sets project attributes.
+ */
+ private void populateProject(Project targetProject, Object buildFile,
+ File buildFileLocation) {
+ AntProject projectAttributes = buildFile.getClass()
+ .getAnnotation(AntProject.class);
+ boolean baseDirSet = false;
+ if (projectAttributes != null) {
+ if (projectAttributes.Name().length() > 0) {
+ targetProject.setName(projectAttributes.Name());
+ }
+ if (projectAttributes.DefaultTarget().length() > 0) {
+ targetProject.setDefault(projectAttributes.DefaultTarget());
+ }
+ if (projectAttributes.BaseDir().length() > 0) {
+ targetProject
+ .setBaseDir(new File(buildFileLocation.getParentFile(),
+ projectAttributes.BaseDir()));
+ baseDirSet = true;
+ }
+ }
+ if (!baseDirSet) {
+ targetProject.setBaseDir(buildFileLocation.getParentFile());
+ }
+ }
+
+ /**
+ * creates targets for methods based on annotations.
+ */
+ private void createTargets(Project targetProject, Object buildFile) {
+ try {
+ for (Method m : buildFile.getClass().getMethods()) {
+ AntTarget t = m.getAnnotation(AntTarget.class);
+ if (t != null) {
+ Class[] params = m.getParameterTypes();
+ if (params.length == 0) {
+ Target target = new Target(m, buildFile);
+ if (t.Name().length() > 0) {
+ target.setName(t.Name());
+ } else {
+ target.setName(m.getName());
+ }
+ if (t.Depends().length() > 0) {
+ target.setDepends(t.Depends());
+ }
+ if (t.If().length() > 0) {
+ target.setIf(t.If());
+ }
+ if (t.Unless().length() > 0) {
+ target.setUnless(t.Unless());
+ }
+ if (t.Description().length() > 0) {
+ target.setDescription(t.Description());
+ }
+ targetProject.addTarget(target);
+ } else {
+ throw new BuildException("Only no-arg methods are"
+ + " supported as targets");
+ }
+ }
+ }
+ } catch (SecurityException e) {
+ throw new BuildException("failed to reflect on "
+ + buildFile.getClass(), e);
+ }
+ }
+}
\ No newline at end of file
Propchange:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/JavaFrontHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/Target.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/Target.java?rev=709148&view=auto
==============================================================================
--- ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/Target.java
(added)
+++ ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/Target.java
Thu Oct 30 04:48:04 2008
@@ -0,0 +1,50 @@
+/*
+ * 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.ant.javafront.helper;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import org.apache.tools.ant.BuildException;
+
+class Target extends org.apache.tools.ant.Target {
+ private final Runnable runnable;
+
+ Target(final Method noArgMethod, final Object buildFile) {
+ runnable = new Runnable() {
+ public void run() {
+ try {
+ noArgMethod.invoke(buildFile);
+ } catch (IllegalAccessException e) {
+ throw new BuildException("failed to invoke noArgMethod"
+ + " in " + buildFile, e);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() instanceof BuildException) {
+ throw (BuildException) e.getCause();
+ }
+ throw new BuildException("failed to invoke noArgMethod"
+ + " in " + buildFile, e);
+ }
+ }
+ };
+ }
+
+ @Override
+ public void execute() {
+ runnable.run();
+ }
+}
\ No newline at end of file
Propchange:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/helper/Target.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: ant/sandbox/javafront/version.properties
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/version.properties?rev=709148&view=auto
==============================================================================
--- ant/sandbox/javafront/version.properties (added)
+++ ant/sandbox/javafront/version.properties Thu Oct 30 04:48:04 2008
@@ -0,0 +1,15 @@
+# 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.
+artifact.version=0.1
Propchange: ant/sandbox/javafront/version.properties
------------------------------------------------------------------------------
svn:eol-style = native