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:11 UTC
(maven-doxia-converter) 03/03: [DOXIATOOLS-81] Convert
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 a2b0e4243ef96b30346586397f17ff011b578900
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Tue Jan 9 22:09:53 2024 +0100
[DOXIATOOLS-81] Convert
---
pom.xml | 2 +-
.../org/apache/maven/doxia/DefaultConverter.java | 2 +-
.../org/apache/maven/doxia/cli/ConverterCli.java | 35 +++++++++++++++++++---
3 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/pom.xml b/pom.xml
index cc63f5c..2d33399 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,7 +55,7 @@ under the License.
</distributionManagement>
<properties>
- <doxiaVersion>2.0.0-M9-SNAPSHOT</doxiaVersion>
+ <doxiaVersion>2.0.0-M9</doxiaVersion>
<javaVersion>8</javaVersion>
<project.build.outputTimestamp>2023-01-09T21:24:22Z</project.build.outputTimestamp>
</properties>
diff --git a/src/main/java/org/apache/maven/doxia/DefaultConverter.java b/src/main/java/org/apache/maven/doxia/DefaultConverter.java
index f4887f0..37df6f9 100644
--- a/src/main/java/org/apache/maven/doxia/DefaultConverter.java
+++ b/src/main/java/org/apache/maven/doxia/DefaultConverter.java
@@ -459,7 +459,7 @@ public class DefaultConverter implements Converter {
containerConfiguration.setName("Doxia");
containerConfiguration.setContext(context);
containerConfiguration.setAutoWiring(true);
- containerConfiguration.setClassPathScanning(PlexusConstants.SCANNING_ON);
+ containerConfiguration.setClassPathScanning(PlexusConstants.SCANNING_INDEX);
plexus = new DefaultPlexusContainer(containerConfiguration);
}
diff --git a/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java b/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java
index a4a2d5d..2998a3e 100644
--- a/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java
+++ b/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java
@@ -23,6 +23,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
import org.apache.commons.cli.CommandLine;
@@ -35,6 +37,13 @@ import org.apache.maven.doxia.UnsupportedFormatException;
import org.apache.maven.doxia.parser.AbstractParser;
import org.apache.maven.doxia.wrapper.InputFileWrapper;
import org.apache.maven.doxia.wrapper.OutputFileWrapper;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.DefaultContainerConfiguration;
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.PlexusContainerException;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.util.Os;
/**
@@ -50,7 +59,7 @@ public class ConverterCli {
* @see #doMain(String[])
* @see System#exit(int)
*/
- public static void main(String[] args) {
+ public static void main(String[] args) throws PlexusContainerException, ComponentLookupException {
if (args == null || args.length == 0) {
args = new String[] {"-h"};
}
@@ -60,7 +69,7 @@ public class ConverterCli {
/**
* @param args The args
*/
- private static int doMain(String[] args) {
+ private static int doMain(String[] args) throws PlexusContainerException, ComponentLookupException {
// ----------------------------------------------------------------------
// Setup the command line parser
// ----------------------------------------------------------------------
@@ -96,12 +105,13 @@ public class ConverterCli {
if (showErrors) {
System.out.println("+ Error stacktraces are turned on.");
}
-
- Converter converter = new DefaultConverter();
if (debug) {
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG");
}
+ PlexusContainer container = getPlexusContainer();
+ Converter converter = container.lookup(Converter.class);
+
InputFileWrapper input;
OutputFileWrapper output;
try {
@@ -202,4 +212,21 @@ public class ConverterCli {
System.err.println("For more information, run with the -e flag");
}
}
+ /**
+ * Start the Plexus container.
+ *
+ * @throws PlexusContainerException if any
+ */
+ private static PlexusContainer getPlexusContainer() throws PlexusContainerException {
+ Map<Object, Object> context = new HashMap<>();
+ context.put("basedir", new File("").getAbsolutePath());
+
+ ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration();
+ containerConfiguration.setName("Doxia");
+ containerConfiguration.setContext(context);
+ containerConfiguration.setAutoWiring(true);
+ containerConfiguration.setClassPathScanning(PlexusConstants.SCANNING_ON);
+
+ return new DefaultPlexusContainer(containerConfiguration);
+ }
}