summaryrefslogtreecommitdiff
path: root/rules/plexus-component-metadata-bootstrap/0002-qdox2.patch
blob: edc9b681143db697eeb4b38995b152550eb6b702 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
From 1913330f81f809db1f29bc61230af818baac5cc6 Mon Sep 17 00:00:00 2001
From: Luke Shumaker <LukeShu@sbcglobal.net>
Date: Fri, 6 Jun 2014 19:49:12 -0400
Subject: [PATCH 2/2] qdox2

---
 .../SourceComponentDescriptorExtractor.java        | 11 +++++-----
 .../metadata/gleaner/QDoxComponentGleaner.java     | 24 +++++++++-------------
 .../metadata/gleaner/SourceComponentGleaner.java   |  4 ++--
 .../metadata/gleaner/QDoxComponentGleanerTest.java |  6 +++---
 4 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/src/main/java/org/codehaus/plexus/metadata/SourceComponentDescriptorExtractor.java b/src/main/java/org/codehaus/plexus/metadata/SourceComponentDescriptorExtractor.java
index 522e9ad..9b357fc 100644
--- a/src/main/java/org/codehaus/plexus/metadata/SourceComponentDescriptorExtractor.java
+++ b/src/main/java/org/codehaus/plexus/metadata/SourceComponentDescriptorExtractor.java
@@ -16,6 +16,7 @@ package org.codehaus.plexus.metadata;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
@@ -24,7 +25,7 @@ import org.codehaus.plexus.metadata.gleaner.QDoxComponentGleaner;
 import org.codehaus.plexus.metadata.gleaner.SourceComponentGleaner;
 import org.codehaus.plexus.util.StringUtils;
 
-import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.JavaProjectBuilder;
 import com.thoughtworks.qdox.model.JavaClass;
 
 /**
@@ -66,7 +67,7 @@ public class SourceComponentDescriptorExtractor
         List<ComponentDescriptor<?>> descriptors = new ArrayList<ComponentDescriptor<?>>();
 
         // Scan the sources
-        JavaDocBuilder builder = new JavaDocBuilder();
+        JavaProjectBuilder builder = new JavaProjectBuilder();
 
         if ( StringUtils.isNotEmpty( sourceEncoding ) )
         {
@@ -80,12 +81,12 @@ public class SourceComponentDescriptorExtractor
             builder.addSourceTree( dir );
         }
 
-        JavaClass[] classes = builder.getClasses();
+        Collection<JavaClass> classes = builder.getClasses();
 
         // For each class we find, try to glean off a descriptor
-        for ( int i = 0; i < classes.length; i++ )
+        for ( JavaClass klass : classes )
         {
-            ComponentDescriptor<?> descriptor = gleaner.glean( builder, classes[i] );
+            ComponentDescriptor<?> descriptor = gleaner.glean( builder, klass );
 
             if ( descriptor != null )
             {
diff --git a/src/main/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleaner.java b/src/main/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleaner.java
index a1396d9..f818fea 100644
--- a/src/main/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleaner.java
+++ b/src/main/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleaner.java
@@ -45,7 +45,7 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
 import org.codehaus.plexus.util.StringUtils;
 
-import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.JavaProjectBuilder;
 import com.thoughtworks.qdox.model.DocletTag;
 import com.thoughtworks.qdox.model.JavaClass;
 import com.thoughtworks.qdox.model.JavaField;
@@ -90,7 +90,7 @@ public class QDoxComponentGleaner
     // ComponentGleaner Implementation
     // ----------------------------------------------------------------------
 
-    public ComponentDescriptor<?> glean( JavaDocBuilder classCache, JavaClass javaClass )
+    public ComponentDescriptor<?> glean( JavaProjectBuilder classCache, JavaClass javaClass )
         throws ComponentGleanerException
     {
         DocletTag tag = javaClass.getTagByName( PLEXUS_COMPONENT_TAG );
@@ -255,7 +255,7 @@ public class QDoxComponentGleaner
         // Remove any Plexus specific interfaces from the calculation
         // ----------------------------------------------------------------------
 
-        List<JavaClass> interfaces = new ArrayList<JavaClass>( Arrays.asList( javaClass.getImplementedInterfaces() ) );
+        List<JavaClass> interfaces = new ArrayList<JavaClass>( javaClass.getImplementedInterfaces() );
 
         for ( Iterator<JavaClass> it = interfaces.iterator(); it.hasNext(); )
         {
@@ -344,10 +344,10 @@ public class QDoxComponentGleaner
         return role;
     }
 
-    private void findRequirements( JavaDocBuilder classCache, ComponentDescriptor<?> componentDescriptor,
+    private void findRequirements( JavaProjectBuilder classCache, ComponentDescriptor<?> componentDescriptor,
                                    JavaClass javaClass )
     {
-        JavaField[] fields = javaClass.getFields();
+        List<JavaField> fields = javaClass.getFields();
 
         // ----------------------------------------------------------------------
         // Search the super class for requirements
@@ -362,10 +362,8 @@ public class QDoxComponentGleaner
         // Search the current class for requirements
         // ----------------------------------------------------------------------
 
-        for ( int i = 0; i < fields.length; i++ )
+        for ( JavaField field : fields )
         {
-            JavaField field = fields[i];
-
             DocletTag tag = field.getTagByName( PLEXUS_REQUIREMENT_TAG );
 
             if ( tag == null )
@@ -379,7 +377,7 @@ public class QDoxComponentGleaner
             // Role
             // ----------------------------------------------------------------------
 
-            String requirementClass = field.getType().getJavaClass().getFullyQualifiedName();
+            String requirementClass = field.getType().getFullyQualifiedName();
 
             boolean isMap = requirementClass.equals( Map.class.getName() ) ||
                     requirementClass.equals( Collection.class.getName() );
@@ -483,7 +481,7 @@ public class QDoxComponentGleaner
     private void findConfiguration( XmlPlexusConfiguration configuration, JavaClass javaClass )
         throws ComponentGleanerException
     {
-        JavaField[] fields = javaClass.getFields();
+        List<JavaField> fields = javaClass.getFields();
 
         // ----------------------------------------------------------------------
         // Search the super class for configurable fields.
@@ -498,10 +496,8 @@ public class QDoxComponentGleaner
         // Search the current class for configurable fields.
         // ----------------------------------------------------------------------
 
-        for ( int i = 0; i < fields.length; i++ )
+        for ( JavaField field : fields )
         {
-            JavaField field = fields[i];
-
             DocletTag tag = field.getTagByName( PLEXUS_CONFIGURATION_TAG );
 
             if ( tag == null )
@@ -565,4 +561,4 @@ public class QDoxComponentGleaner
 
         return value;
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/codehaus/plexus/metadata/gleaner/SourceComponentGleaner.java b/src/main/java/org/codehaus/plexus/metadata/gleaner/SourceComponentGleaner.java
index d8e26c5..6a027c9 100644
--- a/src/main/java/org/codehaus/plexus/metadata/gleaner/SourceComponentGleaner.java
+++ b/src/main/java/org/codehaus/plexus/metadata/gleaner/SourceComponentGleaner.java
@@ -18,7 +18,7 @@ package org.codehaus.plexus.metadata.gleaner;
 
 import org.codehaus.plexus.component.repository.ComponentDescriptor;
 
-import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.JavaProjectBuilder;
 import com.thoughtworks.qdox.model.JavaClass;
 
 /**
@@ -30,6 +30,6 @@ public interface SourceComponentGleaner
 {
     String ROLE = SourceComponentGleaner.class.getName();
 
-    ComponentDescriptor<?> glean( JavaDocBuilder classCache, JavaClass javaClass )
+    ComponentDescriptor<?> glean( JavaProjectBuilder classCache, JavaClass javaClass )
         throws ComponentGleanerException;
 }
\ No newline at end of file
diff --git a/src/test/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleanerTest.java b/src/test/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleanerTest.java
index c94531e..7ac7395 100644
--- a/src/test/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleanerTest.java
+++ b/src/test/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleanerTest.java
@@ -23,7 +23,7 @@ import org.codehaus.plexus.component.repository.ComponentDescriptor;
 import org.codehaus.plexus.component.repository.ComponentRequirement;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 
-import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.JavaProjectBuilder;
 import com.thoughtworks.qdox.model.JavaClass;
 import com.thoughtworks.qdox.model.JavaSource;
 
@@ -37,7 +37,7 @@ public class QDoxComponentGleanerTest
 {
     private QDoxComponentGleaner gleaner;
 
-    private JavaDocBuilder builder;
+    private JavaProjectBuilder builder;
 
     // @Override
     protected void setUp()
@@ -46,7 +46,7 @@ public class QDoxComponentGleanerTest
         super.setUp();
 
         gleaner = new QDoxComponentGleaner();
-        builder = new JavaDocBuilder();
+        builder = new JavaProjectBuilder();
     }
 
     // @Override
-- 
2.0.0