felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1505656 - in /felix/trunk/scrplugin/scrtask: changelog.txt src/main/java/org/apache/felix/scrplugin/ant/SCRDescriptorTask.java
Date Mon, 22 Jul 2013 11:08:16 GMT
Author: cziegeler
Date: Mon Jul 22 11:08:16 2013
New Revision: 1505656

URL: http://svn.apache.org/r1505656
Log:
GRANITE-4175 : scr.ant task does not provide scanClasses option. Apply patch from Daniel Kuffer

Modified:
    felix/trunk/scrplugin/scrtask/changelog.txt
    felix/trunk/scrplugin/scrtask/src/main/java/org/apache/felix/scrplugin/ant/SCRDescriptorTask.java

Modified: felix/trunk/scrplugin/scrtask/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/scrtask/changelog.txt?rev=1505656&r1=1505655&r2=1505656&view=diff
==============================================================================
--- felix/trunk/scrplugin/scrtask/changelog.txt (original)
+++ felix/trunk/scrplugin/scrtask/changelog.txt Mon Jul 22 11:08:16 2013
@@ -1,6 +1,7 @@
 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 
 

Modified: felix/trunk/scrplugin/scrtask/src/main/java/org/apache/felix/scrplugin/ant/SCRDescriptorTask.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/scrtask/src/main/java/org/apache/felix/scrplugin/ant/SCRDescriptorTask.java?rev=1505656&r1=1505655&r2=1505656&view=diff
==============================================================================
--- felix/trunk/scrplugin/scrtask/src/main/java/org/apache/felix/scrplugin/ant/SCRDescriptorTask.java
(original)
+++ felix/trunk/scrplugin/scrtask/src/main/java/org/apache/felix/scrplugin/ant/SCRDescriptorTask.java
Mon Jul 22 11:08:16 2013
@@ -59,6 +59,12 @@ public class SCRDescriptorTask extends M
     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.
      *
@@ -131,11 +137,20 @@ public class SCRDescriptorTask extends M
         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(".java") ) {
+
+                if ( file.getName().endsWith(ext) ) {
                     result.add(new Source() {
 
                         public File getFile() {
@@ -144,7 +159,7 @@ public class SCRDescriptorTask extends M
 
                         public String getClassName() {
                             String name = file.getAbsolutePath().substring(prefixLength).replace(File.separatorChar,
'/').replace('/', '.');
-                            return name.substring(0, name.length() - 5);
+                            return name.substring(0, name.length() - ext.length());
                         }
                     });
                 }
@@ -216,4 +231,12 @@ public class SCRDescriptorTask extends M
     public void setSpecVersion( String specVersion ) {
         this.specVersion = specVersion;
     }
+
+    public boolean isScanClasses() {
+        return scanClasses;
+    }
+
+    public void setScanClasses(boolean scanClasses) {
+        this.scanClasses = scanClasses;
+    }
 }



Mime
View raw message