You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2024/01/09 21:10:10 UTC

(maven-doxia-converter) 02/03: [DOXIATOOLS-81] Inject beans

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch DOXIATOOLS-81
in repository https://gitbox.apache.org/repos/asf/maven-doxia-converter.git

commit 4927a2f62d2844c1a1dd6780c65ae925965b17e5
Author: Sylwester Lachiewicz <sl...@gmail.com>
AuthorDate: Sat Dec 30 21:47:09 2023 +0100

    [DOXIATOOLS-81] Inject beans
---
 pom.xml                                            |   9 +-
 .../org/apache/maven/doxia/DefaultConverter.java   |   9 +-
 src/main/resources/META-INF/plexus/components.xml  | 232 ---------------------
 .../java/org/apache/maven/doxia/ConverterTest.java |   7 +-
 4 files changed, 15 insertions(+), 242 deletions(-)

diff --git a/pom.xml b/pom.xml
index 66af8cf..cc63f5c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,7 +55,7 @@ under the License.
   </distributionManagement>
 
   <properties>
-    <doxiaVersion>2.0.0-M6</doxiaVersion>
+    <doxiaVersion>2.0.0-M9-SNAPSHOT</doxiaVersion>
     <javaVersion>8</javaVersion>
     <project.build.outputTimestamp>2023-01-09T21:24:22Z</project.build.outputTimestamp>
   </properties>
@@ -150,8 +150,7 @@ under the License.
     <dependency>
       <groupId>com.google.inject</groupId>
       <artifactId>guice</artifactId>
-      <version>4.2.3</version>
-      <classifier>no_aop</classifier>
+      <version>6.0.0</version>
     </dependency>
     <dependency>
       <groupId>org.eclipse.sisu</groupId>
@@ -182,6 +181,10 @@ under the License.
       </plugins>
     </pluginManagement>
     <plugins>
+      <plugin>
+        <groupId>org.eclipse.sisu</groupId>
+        <artifactId>sisu-maven-plugin</artifactId>
+      </plugin>
       <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
         <version>3.6.0</version>
diff --git a/src/main/java/org/apache/maven/doxia/DefaultConverter.java b/src/main/java/org/apache/maven/doxia/DefaultConverter.java
index 17e2ee5..f4887f0 100644
--- a/src/main/java/org/apache/maven/doxia/DefaultConverter.java
+++ b/src/main/java/org/apache/maven/doxia/DefaultConverter.java
@@ -18,6 +18,8 @@
  */
 package org.apache.maven.doxia;
 
+import javax.inject.Named;
+
 import java.io.BufferedInputStream;
 import java.io.CharArrayWriter;
 import java.io.File;
@@ -73,6 +75,7 @@ import static java.lang.String.format;
  *
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
  */
+@Named
 public class DefaultConverter implements Converter {
     /**
      * All supported Doxia formats (either only parser, only sink or both)
@@ -142,7 +145,7 @@ public class DefaultConverter implements Converter {
             }
             Objects.requireNonNull(plexus, "plexus is required");
 
-            return (Parser) plexus.lookup(Parser.class, roleHint);
+            return plexus.lookup(Parser.class, roleHint);
         }
 
         /**
@@ -157,7 +160,7 @@ public class DefaultConverter implements Converter {
             }
             Objects.requireNonNull(plexus, "plexus is required");
 
-            return (SinkFactory) plexus.lookup(SinkFactory.class, roleHint);
+            return plexus.lookup(SinkFactory.class, roleHint);
         }
 
         /**
@@ -456,7 +459,7 @@ public class DefaultConverter implements Converter {
         containerConfiguration.setName("Doxia");
         containerConfiguration.setContext(context);
         containerConfiguration.setAutoWiring(true);
-        containerConfiguration.setClassPathScanning(PlexusConstants.SCANNING_INDEX);
+        containerConfiguration.setClassPathScanning(PlexusConstants.SCANNING_ON);
 
         plexus = new DefaultPlexusContainer(containerConfiguration);
     }
diff --git a/src/main/resources/META-INF/plexus/components.xml b/src/main/resources/META-INF/plexus/components.xml
deleted file mode 100644
index a843948..0000000
--- a/src/main/resources/META-INF/plexus/components.xml
+++ /dev/null
@@ -1,232 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-  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.
--->
-
-<component-set>
-  <!-- Doxia core -->
-  <components>
-    <component>
-      <role>org.apache.maven.doxia.macro.Macro</role>
-      <role-hint>echo</role-hint>
-      <implementation>org.apache.maven.doxia.macro.EchoMacro</implementation>
-      <description>A simple macro that prints out the key and value of some supplied
-      parameters.</description>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.macro.manager.MacroManager</role>
-      <implementation>org.apache.maven.doxia.macro.manager.DefaultMacroManager</implementation>
-      <description>Default implementation of &lt;code&gt;MacroManager&lt;/code&gt;</description>
-      <requirements>
-        <requirement>
-          <role>org.apache.maven.doxia.macro.Macro</role>
-          <field-name>macros</field-name>
-        </requirement>
-      </requirements>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.macro.Macro</role>
-      <role-hint>snippet</role-hint>
-      <implementation>org.apache.maven.doxia.macro.snippet.SnippetMacro</implementation>
-      <description>A macro that prints out the content of a file or a URL.</description>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.macro.Macro</role>
-      <role-hint>swf</role-hint>
-      <implementation>org.apache.maven.doxia.macro.SwfMacro</implementation>
-      <description>Macro for embedding Flash (SWF) within Maven documentation.</description>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.macro.Macro</role>
-      <role-hint>toc</role-hint>
-      <implementation>org.apache.maven.doxia.macro.toc.TocMacro</implementation>
-      <description>Macro to display a &lt;code&gt;Table Of Content&lt;/code&gt; in a
-        given &lt;code&gt;Sink&lt;/code&gt;.</description>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.parser.manager.ParserManager</role>
-      <implementation>org.apache.maven.doxia.parser.manager.DefaultParserManager</implementation>
-      <description>Simple implementation of the
-        &lt;code&gt;ParserManager&lt;/code&gt; interface.</description>
-      <requirements>
-        <requirement>
-          <role>org.apache.maven.doxia.parser.Parser</role>
-          <field-name>parsers</field-name>
-        </requirement>
-      </requirements>
-    </component>
-
-    <!-- Doxia apt -->
-    <component>
-      <role>org.apache.maven.doxia.parser.Parser</role>
-      <role-hint>apt</role-hint>
-      <implementation>org.apache.maven.doxia.module.apt.AptParser</implementation>
-      <description>The APT parser.</description>
-      <requirements>
-        <requirement>
-          <role>org.apache.maven.doxia.macro.manager.MacroManager</role>
-          <field-name>macroManager</field-name>
-        </requirement>
-      </requirements>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.sink.SinkFactory</role>
-      <role-hint>apt</role-hint>
-      <implementation>org.apache.maven.doxia.module.apt.AptSinkFactory</implementation>
-      <description>APT implementation of the Sink factory.</description>
-    </component>
-
-    <!-- Doxia confluence -->
-    <component>
-      <role>org.apache.maven.doxia.parser.Parser</role>
-      <role-hint>confluence</role-hint>
-      <implementation>org.apache.maven.doxia.module.confluence.ConfluenceParser</implementation>
-      <description>Parse the &lt;a href=&quot;http://www.</description>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.sink.SinkFactory</role>
-      <role-hint>confluence</role-hint>
-      <implementation>org.apache.maven.doxia.module.confluence.ConfluenceSinkFactory</implementation>
-      <description>Confluence implementation of the Sink factory.</description>
-    </component>
-
-    <!-- Doxia docbook -->
-    <component>
-      <role>org.apache.maven.doxia.parser.Parser</role>
-      <role-hint>docbook</role-hint>
-      <implementation>org.apache.maven.doxia.module.docbook.DocBookParser</implementation>
-      <description>Parse a &lt;code&gt;Docbook&lt;/code&gt; document and emit events
-        into the specified doxia Sink.</description>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.sink.SinkFactory</role>
-      <role-hint>docbook</role-hint>
-      <implementation>org.apache.maven.doxia.module.docbook.DocbookSinkFactory</implementation>
-      <description>Docbook implementation of the Sink factory.</description>
-    </component>
-
-    <!-- Doxia fml -->
-    <component>
-      <role>org.apache.maven.doxia.parser.Parser</role>
-      <role-hint>fml</role-hint>
-      <implementation>org.apache.maven.doxia.module.fml.FmlParser</implementation>
-      <description>Parse a fml model and emit events into the specified doxia Sink.</description>
-      <requirements>
-        <requirement>
-          <role>org.apache.maven.doxia.macro.manager.MacroManager</role>
-          <field-name>macroManager</field-name>
-        </requirement>
-      </requirements>
-    </component>
-
-    <!-- Doxia fo -->
-    <component>
-      <role>org.apache.maven.doxia.sink.SinkFactory</role>
-      <role-hint>fo</role-hint>
-      <implementation>org.apache.maven.doxia.module.fo.FoSinkFactory</implementation>
-      <description>FO implementation of the Sink factory.</description>
-    </component>
-
-    <!-- Doxia itext -->
-    <component>
-      <role>org.apache.maven.doxia.sink.SinkFactory</role>
-      <role-hint>itext</role-hint>
-      <implementation>org.apache.maven.doxia.module.itext.ITextSinkFactory</implementation>
-      <description>IText implementation of the Sink factory.</description>
-    </component>
-
-    <!-- Doxia latex -->
-    <component>
-      <role>org.apache.maven.doxia.sink.SinkFactory</role>
-      <role-hint>latex</role-hint>
-      <implementation>org.apache.maven.doxia.module.latex.LatexSinkFactory</implementation>
-      <description>Latex implementation of the Sink factory.</description>
-    </component>
-
-    <!-- Doxia rtf -->
-    <component>
-      <role>org.apache.maven.doxia.sink.SinkFactory</role>
-      <role-hint>rtf</role-hint>
-      <implementation>org.apache.maven.doxia.module.rtf.RtfSinkFactory</implementation>
-      <description>APT implementation of the Sink factory.</description>
-    </component>
-
-    <!-- Doxia twiki -->
-    <component>
-      <role>org.apache.maven.doxia.parser.Parser</role>
-      <role-hint>twiki</role-hint>
-      <implementation>org.apache.maven.doxia.module.twiki.TWikiParser</implementation>
-      <description>Parse the &lt;a href=&quot;http://twiki.</description>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.sink.SinkFactory</role>
-      <role-hint>twiki</role-hint>
-      <implementation>org.apache.maven.doxia.module.twiki.TWikiSinkFactory</implementation>
-      <description>TWiki implementation of the Sink factory.</description>
-    </component>
-
-    <!-- Doxia xdoc -->
-    <component>
-      <role>org.apache.maven.doxia.parser.Parser</role>
-      <role-hint>xdoc</role-hint>
-      <implementation>org.apache.maven.doxia.module.xdoc.XdocParser</implementation>
-      <description>Parse an xdoc model and emit events into the specified doxia Sink.</description>
-      <requirements>
-        <requirement>
-          <role>org.apache.maven.doxia.macro.manager.MacroManager</role>
-          <field-name>macroManager</field-name>
-        </requirement>
-      </requirements>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.sink.SinkFactory</role>
-      <role-hint>xdoc</role-hint>
-      <implementation>org.apache.maven.doxia.module.xdoc.XdocSinkFactory</implementation>
-      <description>Xdoc implementation of the Sink factory.</description>
-    </component>
-
-    <!-- Doxia xhtml -->
-    <component>
-      <role>org.apache.maven.doxia.parser.Parser</role>
-      <role-hint>xhtml</role-hint>
-      <implementation>org.apache.maven.doxia.module.xhtml.XhtmlParser</implementation>
-      <description>Parse an xhtml model and emit events into a Doxia Sink.</description>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.sink.SinkFactory</role>
-      <role-hint>xhtml</role-hint>
-      <implementation>org.apache.maven.doxia.module.xhtml.XhtmlSinkFactory</implementation>
-      <description>Xhtml implementation of the Sink factory.</description>
-    </component>
-
-    <!-- Doxia xhtml5 -->
-    <component>
-      <role>org.apache.maven.doxia.parser.Parser</role>
-      <role-hint>xhtml5</role-hint>
-      <implementation>org.apache.maven.doxia.module.xhtml5.Xhtml5Parser</implementation>
-      <description>Parse an xhtml5 model and emit events into a Doxia Sink.</description>
-    </component>
-    <component>
-      <role>org.apache.maven.doxia.sink.SinkFactory</role>
-      <role-hint>xhtml5</role-hint>
-      <implementation>org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory</implementation>
-      <description>Xhtml5 implementation of the Sink factory.</description>
-    </component>
-  </components>
-</component-set>
diff --git a/src/test/java/org/apache/maven/doxia/ConverterTest.java b/src/test/java/org/apache/maven/doxia/ConverterTest.java
index 39d30bd..32f7d7f 100644
--- a/src/test/java/org/apache/maven/doxia/ConverterTest.java
+++ b/src/test/java/org/apache/maven/doxia/ConverterTest.java
@@ -18,6 +18,8 @@
  */
 package org.apache.maven.doxia;
 
+import javax.inject.Inject;
+
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -50,6 +52,7 @@ import static org.junit.jupiter.api.Assertions.fail;
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
  */
 class ConverterTest extends InjectedTest {
+    @Inject
     private Converter converter;
 
     private boolean formatOutput;
@@ -58,9 +61,6 @@ class ConverterTest extends InjectedTest {
     @BeforeEach
     public void setUp() throws Exception {
         super.setUp();
-
-        converter = new DefaultConverter();
-
         formatOutput = Boolean.parseBoolean(System.getProperty("format", "false"));
     }
 
@@ -68,7 +68,6 @@ class ConverterTest extends InjectedTest {
     @AfterEach
     public void tearDown() throws Exception {
         super.tearDown();
-
         converter = null;
     }