[maven-release-plugin] copy for tag org.apache.felix.scr.ant-1.18.0
git-svn-id: https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.scr.ant-1.18.0@1820838 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.scr.ant/changelog.txt b/org.apache.felix.scr.ant/changelog.txt
new file mode 100644
index 0000000..9785d91
--- /dev/null
+++ b/org.apache.felix.scr.ant/changelog.txt
@@ -0,0 +1,206 @@
+Changes from 1.18.0 to 1.19.0
+-----------------------------
+** Bug
+ * [FELIX-5464] - java.lang.NullPointerException at org.apache.felix.scrplugin.helper.ClassScanner.processClass(ClassScanner.java:207)
+ * [FELIX-5729] - NoSuchFieldError when @Reference referenceInterface type different than field type
+ * [FELIX-5730] - Different separators in localization attribute
+ * [FELIX-5771] - Metatype generation via bnd plugin creates incorrect file names
+
+
+Changes from 1.17.0 to 1.18.0
+-----------------------------
+** Bug
+ * [FELIX-5700] - Metatype generation wrongly puts properties files into metatype directory
+
+
+Changes from 1.17.0 to 1.16.0
+---------------------------
+** Bug
+ * [FELIX-5451] - Input/Output streams not properly closed in org.apache.felix.scr.generator
+ * [FELIX-5452] - SCR bnd plugin fails when embedding jars with optional/excluded dependencies
+
+
+Changes from 1.16.0 to 1.15.0
+-----------------------------
+** Improvement
+ * [FELIX-5373] - Improve failure message when enabling metatype and using no or private properties only
+** Bug
+ * [FELIX-5304] - SERVICE_PID property should not be created
+ * [FELIX-5328] - NoClassDefFound not wrapped in the ClassScanner
+ * [FELIX-5345] - Incorrect encoding in metatype props file
+
+
+Changes from 1.15.0 to 1.14.0
+-----------------------------
+** Bug
+ * [FELIX-5118] - Exception when running on jdk9-ea
+
+
+Changes from 1.14.0 to 1.13.0
+-----------------------------
+** Improvement
+ * [FELIX-4773] - Generated service component xml does not conform to XSD
+** Bug
+ * [FELIX-4861] - Metatype generation should fail if there is no configuration property
+ * [FELIX-4622] - Regression: SCR spec version detection incorrect for activate method
+ * [FELIX-4774] - Support for @Reference annotation with unbind method "-"
+
+
+Changes from 1.13.0 to 1.11.0
+-----------------------------
+** Improvement
+ * [FELIX-4586] - A field must be volatile if methods are generated for a dynamic reference
+** Bug
+ * [FELIX-4296] - Cannot deactivate service interface detection in DS annotations
+ * [FELIX-4587] - Update method is not verified
+
+
+Changes from 1.11.0 to 1.10.0
+-----------------------------
+** Improvement
+ * [FELIX-4461] - Update to ASM 5 for Java 8 compatibility
+
+
+Changes from 1.10.0 to 1.9.0
+----------------------------
+** Improvement
+ * [FELIX-4378] - Generate a metatype properties file if label/description are missing on @Component or @Property
+** Bug
+ * [FELIX-4379] - Properties, references and services from inherited classes are only used if the class has the component annotation
+ * [FELIX-4383] - Metatype generation should use component name (and not classname)
+ * [FELIX-4441] - The default value is not escaped correctly.
+ * [FELIX-4442] - Lifecycle methods with wrong arguments should be treated as an error
+
+
+Changes from 1.9.0 to 1.8.0
+---------------------------
+** Improvement
+ * [FELIX-4249] - Make the default error location 1,1 instead of 0,0
+** Bug
+ * [FELIX-4192] - SCR Generator fails with a NPE in case a class level Reference doesn't define a referenceInterface
+ * [FELIX-4010] - SCR Plugin aborts when scanning a Java 8 class file
+
+
+Changes from 1.8.0 to 1.7.0
+---------------------------
+** Improvement
+ * [FELIX-4175] - scr.ant task does not provide scanClasses option
+ * [FELIX-4101] - Create metatype.properties file when description and label are inlined
+ * [FELIX-4126] - Discontinue creation of single XML descriptor files
+ * [FELIX-4170] - Deprecate inheritance of component descriptors
+
+
+Changes from 1.7.0 to 1.6.0
+---------------------------
+** Bug
+ * [FELIX-4058] - PropertyType password has a wrong type (passwort)
+
+
+Changes from 1.6.0 to 1.5.0
+---------------------------
+** Improvement
+ * [FELIX-4033] - Issue warning messages for redundant SCR annotation combinations and an error for declaring the service.id property
+ * [FELIX-4035] - Issue warning messages when metatype is be created, but no properties are defined
+** Bug
+ * [FELIX-4030] - Generated metatype file contains all metatype infos
+ * [FELIX-3542] - Escape property values used as Metatype default values
+
+
+Changes from 1.5.0 to 1.4.0
+----------------------------
+** Bug
+ * [FELIX-3917] - bind/unbind methods are not generated
+
+Changes from 1.4.0 to 1.3.0
+----------------------------
+** Improvement
+ * [FELIX-3794] - Use DS specification version per component
+ * [FELIX-3636] - Using @Service without @Component should log a warning
+ * [FELIX-2929] - Read @Property from interfaces of types annotated with @Component
+ * [FELIX-3169] - Add support for new PASSWORD attribute type of Metatype service
+ * [FELIX-3886] - Improve error message for empty *.java-File
+
+** Task
+ * [FELIX-3867] - Drop support for JDK 1.4 completely
+
+** Bug
+ * [FELIX-3815] - Maven SCR Plugin does not correctly set specVersion to 1.1 if bind method with two parameters are used (OSGi Comp 4.2 $112.3.1)
+ * [FELIX-3858] - Service descriptor written in wrong encoding
+ * [FELIX-3232] - SCR annotations @Activate @Deactivate @Modified in outer classes also affect nested classes, annotations in nested classes are ignored
+
+
+Changes from 1.3.0 to 1.2.0
+---------------------------
+** Improvement
+ * [FELIX-3641] - Option to generate separate descriptor files
+
+** Bug
+ * [FELIX-3788] - specVersion incorrectly determined, depends on class order
+ * [FELIX-3568] - java.lang.VerifyError from bundles compiled with maven-scr-plugin (java 7)
+ * [FELIX-3739] - scr-plugin: "Annotated method {0} not found"
+ * [FELIX-3793] - Property of type Character must use unicode value
+ * [FELIX-3653] - Define the "@Reference" annotation on class level without a "referenceInterface" parameter.
+
+
+Changes from 1.1.4 to 1.2.0
+---------------------------
+
+** Task
+ * [FELIX-3225] - Drop javadoc annotation support
+ * [FELIX-3552] - Implement new features of DS 1.2
+ * [FELIX-3550] - Reimplement the SCR Generator
+
+** Bug
+ * [FELIX-3571] - "Comparison method violates general contract!" error in maven-scr-plugin
+ * [FELIX-3510] - Non java files will be processed
+ * [FELIX-3269] - @Property is not properly parsed.
+ * [FELIX-3189] - Mixing full-qualified Reference annotations and imported one results in no References exported to seviceComponents.xml
+ * [FELIX-3606] - SCR Plugin: build failure on wildcard imports (e.g. java.util.*)
+ * [FELIX-3234] - @Property annotation raises exceptions on longValue=0L use
+
+** Improvement
+ * [FELIX-3509] - Undocumented features "strictMode", "parseJavadoc" and "processAnnotations"
+ * [FELIX-2689] - Upgrade Descriptor generator to new parent POM and adapt legal files
+
+
+Changes from 1.1.2 to 1.1.4
+---------------------------
+
+** Bug
+ * [FELIX-2963] - scr annotations @Activate @Deactivate @Modified are not detected with class inheritance
+ * [FELIX-3117] - NullPointerException when not implementing interface that is defined with @Service
+ * [FELIX-3136] - Endless loop: JavaClassDescriptorManager.getJavaClassDescription()
+ * [FELIX-3113] - NPE in multi-module Maven project
+
+
+Changes from 1.1.0 to 1.1.2
+---------------------------
+
+** Bug
+ * [FELIX-2978] - Lookup reference policy does not work for inherited components
+ * [FELIX-2945] - SCR plugin: Parsing of "options" for property tag broken for java annotations
+ * [FELIX-2906] - @Property(cardinality=Integer.MAX_Int, ...) causes java.lang.NumberFormatException
+
+** Improvement
+ * [FELIX-2492] - scr plugin: using src annotations causes NoClassDefFoundError and other errors
+ * [FELIX-2908] - Use same mechanism to get single annotation values as for multiple annotation values
+
+
+Changes from 1.0.0 to 1.1.0
+---------------------------
+
+** Bug
+ * [FELIX-2704] - @Property(cardinality=Integer.MAX_Int, ...) causes java.lang.NumberFormatException
+ * [FELIX-2835] - SCR plugin: Parsing of "options" for property tag broken for javadoc annotations
+ * [FELIX-2731] - NPE while scanning sources with QDox
+ * [FELIX-2876] - <reference> element not generated when name is missing
+
+** Improvement
+ * [FELIX-2853] - Deprecate javadoc tags
+ * [FELIX-2753] - Support array of classes for @Service annotation
+ * [FELIX-2874] - Add new scopes to SlingFilter annotation and use new property names
+ * [FELIX-2838] - Allow classes to be specifed as values for the @Property annotation
+ * [FELIX-2863] - Warnings and error messages contain @scr.* if annotations are used
+ * [FELIX-2690] - Add changelog.txt to SCR/Metatype generation modules
+
+
diff --git a/org.apache.felix.scr.ant/pom.xml b/org.apache.felix.scr.ant/pom.xml
new file mode 100644
index 0000000..5810dd7
--- /dev/null
+++ b/org.apache.felix.scr.ant/pom.xml
@@ -0,0 +1,110 @@
+<!--
+ 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>felix-parent</artifactId>
+ <version>4</version>
+ <relativePath>../../pom/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.ant</artifactId>
+
+ <version>1.18.0</version>
+ <packaging>jar</packaging>
+
+ <name>SCR Ant Task</name>
+ <description>
+ Implements the Ant Task to generate Declarative Services and Metatype
+ Service descriptors from Java 5 annotations and/or JavaDoc tags.
+ </description>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.scr.ant-1.18.0</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.scr.ant-1.18.0</developerConnection>
+ <url>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.scr.ant-1.18.0</url>
+ </scm>
+
+ <properties>
+ <felix.java.version>6</felix.java.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.7.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.generator</artifactId>
+ <version>1.18.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <version>1.12.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.ds-annotations</artifactId>
+ <version>1.2.10</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm-all</artifactId>
+ <version>5.1</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- unpack qdox, asm and annotations into bundle package -->
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ <configuration>
+ <includeArtifactIds>
+ org.apache.felix.scr.generator,asm-all,org.apache.felix.scr.annotations,org.apache.felix.scr.ds-annotations
+ </includeArtifactIds>
+ <outputDirectory>
+ ${project.build.outputDirectory}
+ </outputDirectory>
+ <excludes>
+ **/MANIFEST.MF
+ </excludes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/org.apache.felix.scr.ant/src/main/appended-resources/META-INF/DEPENDENCIES b/org.apache.felix.scr.ant/src/main/appended-resources/META-INF/DEPENDENCIES
new file mode 100644
index 0000000..2725f76
--- /dev/null
+++ b/org.apache.felix.scr.ant/src/main/appended-resources/META-INF/DEPENDENCIES
@@ -0,0 +1,18 @@
+I. Included Third-Party Software
+
+This product includes software developed at http://asm.objectweb.org
+Copyright (c) 2000-2011 INRIA, France Telecom
+Licensed under the BSD License.
+
+
+II. Used Third-Party Software
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2009).
+Licensed under the Apache License 2.0.
+
+
+III. License Summary
+- Apache License 2.0
+- BSD License
diff --git a/org.apache.felix.scr.ant/src/main/appended-resources/META-INF/LICENSE b/org.apache.felix.scr.ant/src/main/appended-resources/META-INF/LICENSE
new file mode 100644
index 0000000..acc4bbd
--- /dev/null
+++ b/org.apache.felix.scr.ant/src/main/appended-resources/META-INF/LICENSE
@@ -0,0 +1,31 @@
+For the asm component:
+
+Copyright (c) 2000-2005 INRIA, France Telecom
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/org.apache.felix.scr.ant/src/main/appended-resources/META-INF/NOTICE b/org.apache.felix.scr.ant/src/main/appended-resources/META-INF/NOTICE
new file mode 100644
index 0000000..47119b9
--- /dev/null
+++ b/org.apache.felix.scr.ant/src/main/appended-resources/META-INF/NOTICE
@@ -0,0 +1,7 @@
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at http://asm.objectweb.org
+Copyright (c) 2000-2011 INRIA, France Telecom
+Licensed under the BSD License.
diff --git a/org.apache.felix.scr.ant/src/main/java/org/apache/felix/scrplugin/ant/AntLog.java b/org.apache.felix.scr.ant/src/main/java/org/apache/felix/scrplugin/ant/AntLog.java
new file mode 100644
index 0000000..076620a
--- /dev/null
+++ b/org.apache.felix.scr.ant/src/main/java/org/apache/felix/scrplugin/ant/AntLog.java
@@ -0,0 +1,160 @@
+/*
+ * 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.felix.scrplugin.ant;
+
+
+import org.apache.felix.scrplugin.Log;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+
+public class AntLog implements Log
+{
+
+ private final Task task;
+
+
+ AntLog( final Task task )
+ {
+ this.task = task;
+ }
+
+
+ public boolean isDebugEnabled()
+ {
+ // cannot tell, assume yes
+ return true;
+ }
+
+
+ public void debug( String content )
+ {
+ task.log( content, Project.MSG_DEBUG );
+ }
+
+
+ public void debug( String content, Throwable error )
+ {
+ task.log( content, error, Project.MSG_DEBUG );
+ }
+
+
+ public void debug( Throwable error )
+ {
+ task.log( error, Project.MSG_DEBUG );
+ }
+
+
+ public boolean isInfoEnabled()
+ {
+ // cannot tell, assume yes
+ return true;
+ }
+
+
+ public void info( String content )
+ {
+ task.log( content, Project.MSG_INFO );
+ }
+
+
+ public void info( String content, Throwable error )
+ {
+ task.log( content, error, Project.MSG_INFO );
+ }
+
+
+ public void info( Throwable error )
+ {
+ task.log( error, Project.MSG_INFO );
+ }
+
+
+ public boolean isWarnEnabled()
+ {
+ // cannot tell, assume yes
+ return true;
+ }
+
+
+ public void warn( String content )
+ {
+ task.log( content, Project.MSG_WARN );
+ }
+
+
+ public void warn( String content, String location, int lineNumber )
+ {
+ warn( String.format( "%s [%s,%d]", content, location, lineNumber ) );
+ }
+
+ public void warn( String content, String location, int lineNumber, int columNumber )
+ {
+ warn( String.format( "%s [%s,%d:%d]", content, location, lineNumber , columNumber) );
+ }
+
+
+ public void warn( String content, Throwable error )
+ {
+ task.log( content, error, Project.MSG_WARN );
+ }
+
+
+ public void warn( Throwable error )
+ {
+ task.log( error, Project.MSG_WARN );
+ }
+
+
+ public boolean isErrorEnabled()
+ {
+ // cannot tell, assume yes
+ return true;
+ }
+
+
+ public void error( String content )
+ {
+ task.log( content, Project.MSG_ERR );
+ }
+
+
+ public void error( String content, String location, int lineNumber )
+ {
+ error( String.format( "%s [%s,%d]", content, location, lineNumber ) );
+ }
+
+ public void error( String content, String location, int lineNumber, int columnNumber )
+ {
+ error( String.format( "%s [%s,%d:%d]", content, location, lineNumber, columnNumber ) );
+ }
+
+
+ public void error( String content, Throwable error )
+ {
+ task.log( content, error, Project.MSG_ERR );
+ }
+
+
+ public void error( Throwable error )
+ {
+ task.log( error, Project.MSG_ERR );
+ }
+
+}
diff --git a/org.apache.felix.scr.ant/src/main/java/org/apache/felix/scrplugin/ant/SCRDescriptorTask.java b/org.apache.felix.scr.ant/src/main/java/org/apache/felix/scrplugin/ant/SCRDescriptorTask.java
new file mode 100644
index 0000000..85dd3f7
--- /dev/null
+++ b/org.apache.felix.scr.ant/src/main/java/org/apache/felix/scrplugin/ant/SCRDescriptorTask.java
@@ -0,0 +1,242 @@
+/*
+ * 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.felix.scrplugin.ant;
+
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.felix.scrplugin.Options;
+import org.apache.felix.scrplugin.SCRDescriptorException;
+import org.apache.felix.scrplugin.SCRDescriptorFailureException;
+import org.apache.felix.scrplugin.SCRDescriptorGenerator;
+import org.apache.felix.scrplugin.Source;
+import org.apache.felix.scrplugin.SpecVersion;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Location;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.resources.FileResource;
+
+
+/**
+ * The <code>SCRDescriptorTask</code> generates a service descriptor file based
+ * on annotations found in the sources.
+ */
+public class SCRDescriptorTask extends MatchingTask {
+
+ private File destdir;
+
+ private Path classpath;
+
+ /**
+ * This flag controls the generation of the bind/unbind methods.
+ */
+ private boolean generateAccessors = true;
+
+ /**
+ * In strict mode the plugin even fails on warnings.
+ */
+ protected boolean strictMode = false;
+
+ /**
+ * Set to true to scan classes instead of sources.
+ * By default scan sources to be backwards compatible
+ */
+ private boolean scanClasses = false;
+
+ /**
+ * The version of the DS spec this plugin generates a descriptor for. By
+ * default the version is detected by the used tags.
+ *
+ * @parameter
+ */
+ private String specVersion;
+
+
+ @Override
+ public void execute() throws BuildException {
+
+ // ensure we know the source
+ if (getImplicitFileSet().getDir() == null) {
+ throw new BuildException( "srcdir attribute must be set!", getLocation());
+ }
+
+ // while debugging
+ final org.apache.felix.scrplugin.Log scrLog = new AntLog( this );
+
+ scrLog.debug( "SCRDescriptorTask Configuration" );
+ scrLog.debug( " implicitFileset: " + getImplicitFileSet() );
+ scrLog.debug( " outputDirectory: " + destdir );
+ scrLog.debug( " classpath: " + classpath );
+ scrLog.debug( " generateAccessors: " + generateAccessors );
+ scrLog.debug( " strictMode: " + strictMode );
+ scrLog.debug( " specVersion: " + specVersion );
+
+ try {
+ final Path classPath = createClasspath();
+ final org.apache.felix.scrplugin.Project project = new org.apache.felix.scrplugin.Project();
+ project.setClassLoader(getClassLoader( this.getClass().getClassLoader() ));
+
+ project.setDependencies(getDependencies(classPath));
+ project.setSources(getSourceFiles(getImplicitFileSet()));
+ project.setClassesDirectory(destdir.getAbsolutePath());
+
+ // create options
+ final Options options = new Options();
+ options.setOutputDirectory(destdir);
+ options.setGenerateAccessors(generateAccessors);
+ options.setStrictMode(strictMode);
+ options.setProperties(new HashMap<String, String>());
+ options.setSpecVersion(SpecVersion.fromName(specVersion));
+ if ( specVersion != null && options.getSpecVersion() == null ) {
+ throw new BuildException("Unknown spec version specified: " + specVersion);
+ }
+
+ final SCRDescriptorGenerator generator = new SCRDescriptorGenerator( scrLog );
+
+ // setup from plugin configuration
+ generator.setOptions(options);
+ generator.setProject(project);
+
+ generator.execute();
+ } catch ( final SCRDescriptorException sde ) {
+ if ( sde.getSourceLocation() != null ) {
+ final Location loc = new Location( sde.getSourceLocation(), -1, 0 );
+ throw new BuildException( sde.getMessage(), sde.getCause(), loc );
+ }
+ throw new BuildException( sde.getMessage(), sde.getCause() );
+ } catch ( SCRDescriptorFailureException sdfe ) {
+ throw new BuildException( sdfe.getMessage(), sdfe.getCause() );
+ }
+ }
+
+ protected Collection<Source> getSourceFiles(final FileSet sourceFiles) {
+ final String prefix = sourceFiles.getDir().getAbsolutePath();
+ final int prefixLength = prefix.length() + 1;
+
+ final List<Source> result = new ArrayList<Source>();
+ @SuppressWarnings("unchecked")
+ final Iterator<Resource> resources = sourceFiles.iterator();
+
+ final String ext;
+ if(scanClasses) {
+ ext = ".class";
+ } else {
+ ext = ".java";
+ }
+
+ while ( resources.hasNext() ) {
+ final Resource r = resources.next();
+ if ( r instanceof FileResource ) {
+ final File file = ( ( FileResource ) r ).getFile();
+
+ if ( file.getName().endsWith(ext) ) {
+ result.add(new Source() {
+
+ public File getFile() {
+ return file;
+ }
+
+ public String getClassName() {
+ String name = file.getAbsolutePath().substring(prefixLength).replace(File.separatorChar, '/').replace('/', '.');
+ return name.substring(0, name.length() - ext.length());
+ }
+ });
+ }
+ }
+ }
+
+ return result;
+ }
+
+
+ private List<File> getDependencies(final Path classPath) {
+ ArrayList<File> files = new ArrayList<File>();
+ for ( String entry : classPath.list() ) {
+ File file = new File( entry );
+ if ( file.isFile() ) {
+ files.add( file );
+ }
+ }
+ return files;
+ }
+
+ private ClassLoader getClassLoader( final ClassLoader parent ) throws BuildException {
+ Path classPath = createClasspath();
+ log( "Using classes from: " + classPath, Project.MSG_DEBUG );
+ return getProject().createClassLoader( parent, classpath );
+ }
+
+
+ // ---------- setters for configuration fields
+
+ public Path createClasspath() {
+ if ( this.classpath == null ) {
+ this.classpath = new Path( getProject() );
+ }
+ return this.classpath;
+ }
+
+ public void setClasspath( Path classPath ) {
+ createClasspath().add( classPath );
+ }
+
+ public void setClasspathRef( Reference classpathRef ) {
+ if ( classpathRef != null && classpathRef.getReferencedObject() instanceof Path ) {
+ createClasspath().add( ( Path ) classpathRef.getReferencedObject() );
+ }
+ }
+
+ public void setSrcdir( File srcdir ) {
+ getImplicitFileSet().setDir( srcdir );
+ }
+
+ public void setDestdir( File outputDirectory ) {
+ this.destdir = outputDirectory;
+ if ( destdir != null ) {
+ Path dst = new Path( getProject() );
+ dst.setLocation( destdir );
+ createClasspath().add( dst );
+ }
+ }
+
+ public void setGenerateAccessors( boolean generateAccessors ) {
+ this.generateAccessors = generateAccessors;
+ }
+
+ public void setStrictMode( boolean strictMode ) {
+ this.strictMode = strictMode;
+ }
+
+ public void setSpecVersion( String specVersion ) {
+ this.specVersion = specVersion;
+ }
+
+ public boolean isScanClasses() {
+ return scanClasses;
+ }
+
+ public void setScanClasses(boolean scanClasses) {
+ this.scanClasses = scanClasses;
+ }
+}
diff --git a/org.apache.felix.scr.ant/src/main/resources/scrtask.properties b/org.apache.felix.scr.ant/src/main/resources/scrtask.properties
new file mode 100644
index 0000000..d2b975f
--- /dev/null
+++ b/org.apache.felix.scr.ant/src/main/resources/scrtask.properties
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+
+# Define the ANT Tasks provided in this library
+scr=org.apache.felix.scrplugin.ant.SCRDescriptorTask
\ No newline at end of file