1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16- package org .fedoraproject .mbi .tool .cdc ;
16+ package org .fedoraproject .mbi .tool .plexus ;
1717
18- import java .io .PrintWriter ;
1918import java .lang .annotation .Annotation ;
2019import java .lang .reflect .Field ;
2120import java .nio .file .Files ;
2221import java .nio .file .Path ;
23- import java .util .ArrayList ;
24- import java .util .List ;
2522import java .util .stream .Collectors ;
2623
27- import javax .inject .Named ;
2824import javax .xml .parsers .DocumentBuilder ;
2925import javax .xml .parsers .DocumentBuilderFactory ;
3026import javax .xml .transform .OutputKeys ;
4743/**
4844 * @author Mikolaj Izdebski
4945 */
50- public class CdcTool
46+ public class PlexusTool
5147 extends Tool
5248{
5349 private static final String PLEXUS_DESCRIPTOR_PATH = "META-INF/plexus/components.xml" ;
5450
55- private static final String SISU_DESCRIPTOR_PATH = "META-INF/sisu/javax.inject.Named" ;
56-
5751 private DocumentBuilder documentBuilder ;
5852
5953 private Transformer transformer ;
@@ -62,8 +56,6 @@ public class CdcTool
6256
6357 private Element plexusComponents ;
6458
65- private List <String > sisuComponents = new ArrayList <>();
66-
6759 @ Override
6860 public void initialize ()
6961 throws Exception
@@ -145,10 +137,6 @@ private void gleanFromClasses()
145137 String className =
146138 getClassesDir ().relativize ( classFile ).toString ().replaceAll ( ".class$" , "" ).replace ( '/' , '.' );
147139 Class <?> cls = getClass ().getClassLoader ().loadClass ( className );
148- if ( cls .isAnnotationPresent ( Named .class ) )
149- {
150- sisuComponents .add ( cls .getName () );
151- }
152140 if ( cls .isAnnotationPresent ( Component .class ) )
153141 {
154142 Annotation plexus = cls .getAnnotationsByType ( Component .class )[0 ];
@@ -183,7 +171,7 @@ public void execute()
183171 {
184172 gleanFromClasses ();
185173
186- if ( sisuComponents . isEmpty () && !plexusComponents .hasChildNodes () )
174+ if ( !plexusComponents .hasChildNodes () )
187175 {
188176 throw new RuntimeException ( "No Plexus components were discovered by CDC for module "
189177 + getModule ().getName () );
@@ -194,15 +182,5 @@ public void execute()
194182 Source source = new DOMSource ( plexusDescriptor );
195183 Result result = new StreamResult ( plexusPath .toFile () );
196184 transformer .transform ( source , result );
197-
198- Path sisuPath = getClassesDir ().resolve ( SISU_DESCRIPTOR_PATH );
199- Files .createDirectories ( sisuPath .getParent () );
200- try ( PrintWriter pw = new PrintWriter ( Files .newBufferedWriter ( sisuPath ) ) )
201- {
202- for ( String sisuComponent : sisuComponents )
203- {
204- pw .println ( sisuComponent );
205- }
206- }
207185 }
208186}
0 commit comments