From 6a34da5ae0d9c024f64c0c5e96a724d074b2c1f7 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Mon, 31 Jul 2017 13:04:04 +0200 Subject: [PATCH] Group ID refactor and fit requirements to deploy on sonatype.org --- README.md | 4 +- pom.xml | 80 ++++++++++++++++++- .../it/eomm/{plugins => tools}/dolm/Dolm.java | 2 +- .../eomm/{plugins => tools}/dolm/IDolm.java | 2 +- .../dolm/bean/Converted.java | 2 +- .../dolm/exceptions/ConvertException.java | 2 +- .../dolm/exceptions/PipeException.java | 2 +- .../dolm/goals/BuildMojo.java | 27 ++++--- .../dolm/logic/IConverter.java | 4 +- .../dolm/logic/PipelineConverter.java | 4 +- .../converter/MarkdownFileConverter.java | 16 ++-- .../dolm/logic/converter/OutPdf.java | 21 +++-- .../dolm/utils/ConvertFactory.java | 2 +- .../dolm/utils/FileNamePatternFilter.java | 6 +- .../dolm/utils/FileSystemIterator.java | 33 ++++++-- .../dolm/test/DolmTest.java | 6 +- src/test/resources/pom-test.xml | 2 +- 17 files changed, 168 insertions(+), 47 deletions(-) rename src/main/java/it/eomm/{plugins => tools}/dolm/Dolm.java (98%) rename src/main/java/it/eomm/{plugins => tools}/dolm/IDolm.java (92%) rename src/main/java/it/eomm/{plugins => tools}/dolm/bean/Converted.java (95%) rename src/main/java/it/eomm/{plugins => tools}/dolm/exceptions/ConvertException.java (91%) rename src/main/java/it/eomm/{plugins => tools}/dolm/exceptions/PipeException.java (91%) rename src/main/java/it/eomm/{plugins => tools}/dolm/goals/BuildMojo.java (70%) rename src/main/java/it/eomm/{plugins => tools}/dolm/logic/IConverter.java (61%) rename src/main/java/it/eomm/{plugins => tools}/dolm/logic/PipelineConverter.java (88%) rename src/main/java/it/eomm/{plugins => tools}/dolm/logic/converter/MarkdownFileConverter.java (64%) rename src/main/java/it/eomm/{plugins => tools}/dolm/logic/converter/OutPdf.java (78%) rename src/main/java/it/eomm/{plugins => tools}/dolm/utils/ConvertFactory.java (96%) rename src/main/java/it/eomm/{plugins => tools}/dolm/utils/FileNamePatternFilter.java (78%) rename src/main/java/it/eomm/{plugins => tools}/dolm/utils/FileSystemIterator.java (63%) rename src/test/java/it/eomm/{plugins => tools}/dolm/test/DolmTest.java (97%) diff --git a/README.md b/README.md index 6098dc4..5737400 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Once you [installed the lib](https://maven.apache.org/guides/mini/guide-3rd-part - it.eomm.plugins + it.eomm.tools dolm-maven-plugin LATEST @@ -122,7 +122,7 @@ Simply run `mvn clean test` ### Next steps + :white_check_mark: JUnit + :white_check_mark: Better integration in the maven lifecycle -+ :white_medium_square: Deploy on [mvn-repository](http://central.sonatype.org/) ++ :hourglass_flowing_sand: Deploy on [mvn-repository](http://central.sonatype.org/) + :white_medium_square: Add a template system to the `.md` files + :white_medium_square: Customize the output file format (`docx`, `odt`, ecc...) diff --git a/pom.xml b/pom.xml index 1846558..0c16f7c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,15 +1,24 @@ 4.0.0 - it.eomm.plugins + + it.eomm.tools dolm-maven-plugin - 0.0.2 + 1.0.0 maven-plugin DOLM DOLM (Document Lifecycle Management) start with an easy plugin for build PDF docs from any markdown .md files. + https://github.com/Eomm/dolm + + + + MIT License + http://www.opensource.org/licenses/mit-license.php + + UTF-8 @@ -130,9 +139,62 @@ + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.4 + + + attach-javadocs + + jar + + + + + + + + sign-jar + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + + + + + + Manuel Spigolon @@ -142,9 +204,8 @@ scm:git:git@github.com:Eomm/dolm.git - scm:git:git@github.com:Eomm/dolm.git scm:git:git@github.com:Eomm/dolm.git - HEAD + https://github.com/Eomm/dolm/tree/master @@ -152,4 +213,15 @@ GitHub Issues + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + \ No newline at end of file diff --git a/src/main/java/it/eomm/plugins/dolm/Dolm.java b/src/main/java/it/eomm/tools/dolm/Dolm.java similarity index 98% rename from src/main/java/it/eomm/plugins/dolm/Dolm.java rename to src/main/java/it/eomm/tools/dolm/Dolm.java index 5f966c1..50bc8bd 100644 --- a/src/main/java/it/eomm/plugins/dolm/Dolm.java +++ b/src/main/java/it/eomm/tools/dolm/Dolm.java @@ -1,4 +1,4 @@ -package it.eomm.plugins.dolm; +package it.eomm.tools.dolm; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.logging.Log; diff --git a/src/main/java/it/eomm/plugins/dolm/IDolm.java b/src/main/java/it/eomm/tools/dolm/IDolm.java similarity index 92% rename from src/main/java/it/eomm/plugins/dolm/IDolm.java rename to src/main/java/it/eomm/tools/dolm/IDolm.java index 796cd5b..4131ed2 100644 --- a/src/main/java/it/eomm/plugins/dolm/IDolm.java +++ b/src/main/java/it/eomm/tools/dolm/IDolm.java @@ -1,4 +1,4 @@ -package it.eomm.plugins.dolm; +package it.eomm.tools.dolm; import org.apache.maven.plugin.Mojo; diff --git a/src/main/java/it/eomm/plugins/dolm/bean/Converted.java b/src/main/java/it/eomm/tools/dolm/bean/Converted.java similarity index 95% rename from src/main/java/it/eomm/plugins/dolm/bean/Converted.java rename to src/main/java/it/eomm/tools/dolm/bean/Converted.java index f54ddd8..11908e8 100644 --- a/src/main/java/it/eomm/plugins/dolm/bean/Converted.java +++ b/src/main/java/it/eomm/tools/dolm/bean/Converted.java @@ -1,4 +1,4 @@ -package it.eomm.plugins.dolm.bean; +package it.eomm.tools.dolm.bean; import java.io.Serializable; diff --git a/src/main/java/it/eomm/plugins/dolm/exceptions/ConvertException.java b/src/main/java/it/eomm/tools/dolm/exceptions/ConvertException.java similarity index 91% rename from src/main/java/it/eomm/plugins/dolm/exceptions/ConvertException.java rename to src/main/java/it/eomm/tools/dolm/exceptions/ConvertException.java index b1c9405..1dea9fe 100644 --- a/src/main/java/it/eomm/plugins/dolm/exceptions/ConvertException.java +++ b/src/main/java/it/eomm/tools/dolm/exceptions/ConvertException.java @@ -1,4 +1,4 @@ -package it.eomm.plugins.dolm.exceptions; +package it.eomm.tools.dolm.exceptions; public class ConvertException extends Exception { /** diff --git a/src/main/java/it/eomm/plugins/dolm/exceptions/PipeException.java b/src/main/java/it/eomm/tools/dolm/exceptions/PipeException.java similarity index 91% rename from src/main/java/it/eomm/plugins/dolm/exceptions/PipeException.java rename to src/main/java/it/eomm/tools/dolm/exceptions/PipeException.java index 2e861dd..f7f920c 100644 --- a/src/main/java/it/eomm/plugins/dolm/exceptions/PipeException.java +++ b/src/main/java/it/eomm/tools/dolm/exceptions/PipeException.java @@ -1,4 +1,4 @@ -package it.eomm.plugins.dolm.exceptions; +package it.eomm.tools.dolm.exceptions; public class PipeException extends Exception { /** diff --git a/src/main/java/it/eomm/plugins/dolm/goals/BuildMojo.java b/src/main/java/it/eomm/tools/dolm/goals/BuildMojo.java similarity index 70% rename from src/main/java/it/eomm/plugins/dolm/goals/BuildMojo.java rename to src/main/java/it/eomm/tools/dolm/goals/BuildMojo.java index d1799f8..6116073 100644 --- a/src/main/java/it/eomm/plugins/dolm/goals/BuildMojo.java +++ b/src/main/java/it/eomm/tools/dolm/goals/BuildMojo.java @@ -1,13 +1,13 @@ -package it.eomm.plugins.dolm.goals; - -import it.eomm.plugins.dolm.Dolm; -import it.eomm.plugins.dolm.bean.Converted; -import it.eomm.plugins.dolm.logic.PipelineConverter; -import it.eomm.plugins.dolm.logic.converter.MarkdownFileConverter; -import it.eomm.plugins.dolm.logic.converter.OutPdf; -import it.eomm.plugins.dolm.utils.ConvertFactory; -import it.eomm.plugins.dolm.utils.FileNamePatternFilter; -import it.eomm.plugins.dolm.utils.FileSystemIterator; +package it.eomm.tools.dolm.goals; + +import it.eomm.tools.dolm.Dolm; +import it.eomm.tools.dolm.bean.Converted; +import it.eomm.tools.dolm.logic.PipelineConverter; +import it.eomm.tools.dolm.logic.converter.MarkdownFileConverter; +import it.eomm.tools.dolm.logic.converter.OutPdf; +import it.eomm.tools.dolm.utils.ConvertFactory; +import it.eomm.tools.dolm.utils.FileNamePatternFilter; +import it.eomm.tools.dolm.utils.FileSystemIterator; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -22,6 +22,13 @@ @Mojo(name = "build", defaultPhase = LifecyclePhase.PRE_SITE) public class BuildMojo extends Dolm { + /** + * Convert all the files in @{sourcePath} matching the @{filter} filename's pattern to PDF files in the @{outputPath} with @{filenamePatternOutput}.
+ * If there aren't files in the directory the plugins does nothings. + * + * @throws MojoExecutionException when an unexpected error occurs + * @throws MojoFailureException when a parameter is not valid + */ @Override public void execute() throws MojoExecutionException, MojoFailureException { try { diff --git a/src/main/java/it/eomm/plugins/dolm/logic/IConverter.java b/src/main/java/it/eomm/tools/dolm/logic/IConverter.java similarity index 61% rename from src/main/java/it/eomm/plugins/dolm/logic/IConverter.java rename to src/main/java/it/eomm/tools/dolm/logic/IConverter.java index d1549d2..69b6fdc 100644 --- a/src/main/java/it/eomm/plugins/dolm/logic/IConverter.java +++ b/src/main/java/it/eomm/tools/dolm/logic/IConverter.java @@ -1,6 +1,6 @@ -package it.eomm.plugins.dolm.logic; +package it.eomm.tools.dolm.logic; -import it.eomm.plugins.dolm.exceptions.ConvertException; +import it.eomm.tools.dolm.exceptions.ConvertException; /** * Created by Manuel Spigolon on 02/07/2017. diff --git a/src/main/java/it/eomm/plugins/dolm/logic/PipelineConverter.java b/src/main/java/it/eomm/tools/dolm/logic/PipelineConverter.java similarity index 88% rename from src/main/java/it/eomm/plugins/dolm/logic/PipelineConverter.java rename to src/main/java/it/eomm/tools/dolm/logic/PipelineConverter.java index 2e98180..f218332 100644 --- a/src/main/java/it/eomm/plugins/dolm/logic/PipelineConverter.java +++ b/src/main/java/it/eomm/tools/dolm/logic/PipelineConverter.java @@ -1,6 +1,6 @@ -package it.eomm.plugins.dolm.logic; +package it.eomm.tools.dolm.logic; -import it.eomm.plugins.dolm.exceptions.PipeException; +import it.eomm.tools.dolm.exceptions.PipeException; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/it/eomm/plugins/dolm/logic/converter/MarkdownFileConverter.java b/src/main/java/it/eomm/tools/dolm/logic/converter/MarkdownFileConverter.java similarity index 64% rename from src/main/java/it/eomm/plugins/dolm/logic/converter/MarkdownFileConverter.java rename to src/main/java/it/eomm/tools/dolm/logic/converter/MarkdownFileConverter.java index 2c5215e..b50c388 100644 --- a/src/main/java/it/eomm/plugins/dolm/logic/converter/MarkdownFileConverter.java +++ b/src/main/java/it/eomm/tools/dolm/logic/converter/MarkdownFileConverter.java @@ -1,9 +1,9 @@ -package it.eomm.plugins.dolm.logic.converter; +package it.eomm.tools.dolm.logic.converter; -import it.eomm.plugins.dolm.bean.Converted; -import it.eomm.plugins.dolm.exceptions.ConvertException; -import it.eomm.plugins.dolm.logic.IConverter; -import it.eomm.plugins.dolm.utils.ConvertFactory; +import it.eomm.tools.dolm.bean.Converted; +import it.eomm.tools.dolm.exceptions.ConvertException; +import it.eomm.tools.dolm.logic.IConverter; +import it.eomm.tools.dolm.utils.ConvertFactory; import org.commonmark.node.Node; import org.commonmark.parser.Parser; @@ -11,6 +11,7 @@ import java.io.FileReader; /** + * Convert a {@link File} to a Markdown {@link Node} * Created by Manuel Spigolon on 02/07/2017. */ public class MarkdownFileConverter implements IConverter> { @@ -25,6 +26,11 @@ public MarkdownFileConverter(ConvertFactory factory) { this.factory = factory; } + /** + * @param input a {@link File} in the markdown format + * @return a {@link Converted} object with the original {@link File} and the converted {@link Node} + * @throws ConvertException if some unexpected error occurs + */ @Override public Converted convert(File input) throws ConvertException { Parser parser = factory.buildParser(); diff --git a/src/main/java/it/eomm/plugins/dolm/logic/converter/OutPdf.java b/src/main/java/it/eomm/tools/dolm/logic/converter/OutPdf.java similarity index 78% rename from src/main/java/it/eomm/plugins/dolm/logic/converter/OutPdf.java rename to src/main/java/it/eomm/tools/dolm/logic/converter/OutPdf.java index df54fb7..7c4cf2b 100644 --- a/src/main/java/it/eomm/plugins/dolm/logic/converter/OutPdf.java +++ b/src/main/java/it/eomm/tools/dolm/logic/converter/OutPdf.java @@ -1,12 +1,12 @@ -package it.eomm.plugins.dolm.logic.converter; +package it.eomm.tools.dolm.logic.converter; import com.itextpdf.text.Document; import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.tool.xml.XMLWorkerHelper; -import it.eomm.plugins.dolm.bean.Converted; -import it.eomm.plugins.dolm.exceptions.ConvertException; -import it.eomm.plugins.dolm.logic.IConverter; -import it.eomm.plugins.dolm.utils.ConvertFactory; +import it.eomm.tools.dolm.bean.Converted; +import it.eomm.tools.dolm.exceptions.ConvertException; +import it.eomm.tools.dolm.logic.IConverter; +import it.eomm.tools.dolm.utils.ConvertFactory; import org.commonmark.node.Node; import java.io.ByteArrayInputStream; @@ -14,6 +14,9 @@ import java.io.FileOutputStream; import java.util.Date; +/** + * Convert a Markdown {@link Node} to a PDF {@link File}. + */ public class OutPdf implements IConverter, Converted> { private ConvertFactory factory; @@ -32,6 +35,14 @@ public OutPdf(ConvertFactory factory, String outputPath, String outputFileNamePa this.outputFileVersion = outputFileVersion; } + /** + * Convert the input node to a PDF file using {@link PdfWriter}.
+ * If the @{outputPath} doesn't exist it will be created. + * + * @param input a {@link Converted} object with the original file read and the Markdown node. + * @return a {@link Converted} object with the node from input and the {@link File} output + * @throws ConvertException if some error occurs + */ @Override public Converted convert(Converted input) throws ConvertException { File outPath = new File(outputPath); diff --git a/src/main/java/it/eomm/plugins/dolm/utils/ConvertFactory.java b/src/main/java/it/eomm/tools/dolm/utils/ConvertFactory.java similarity index 96% rename from src/main/java/it/eomm/plugins/dolm/utils/ConvertFactory.java rename to src/main/java/it/eomm/tools/dolm/utils/ConvertFactory.java index f8b735b..f1b9c0d 100644 --- a/src/main/java/it/eomm/plugins/dolm/utils/ConvertFactory.java +++ b/src/main/java/it/eomm/tools/dolm/utils/ConvertFactory.java @@ -1,4 +1,4 @@ -package it.eomm.plugins.dolm.utils; +package it.eomm.tools.dolm.utils; import org.commonmark.Extension; import org.commonmark.parser.Parser; diff --git a/src/main/java/it/eomm/plugins/dolm/utils/FileNamePatternFilter.java b/src/main/java/it/eomm/tools/dolm/utils/FileNamePatternFilter.java similarity index 78% rename from src/main/java/it/eomm/plugins/dolm/utils/FileNamePatternFilter.java rename to src/main/java/it/eomm/tools/dolm/utils/FileNamePatternFilter.java index 326c624..e01edd6 100644 --- a/src/main/java/it/eomm/plugins/dolm/utils/FileNamePatternFilter.java +++ b/src/main/java/it/eomm/tools/dolm/utils/FileNamePatternFilter.java @@ -1,4 +1,4 @@ -package it.eomm.plugins.dolm.utils; +package it.eomm.tools.dolm.utils; import java.io.File; import java.io.FilenameFilter; @@ -7,6 +7,10 @@ public class FileNamePatternFilter implements FilenameFilter { private String pattern; + /** + * Filter a java.util.File by his filename + * @param pattern mandatory pattern + */ public FileNamePatternFilter(String pattern) { super(); diff --git a/src/main/java/it/eomm/plugins/dolm/utils/FileSystemIterator.java b/src/main/java/it/eomm/tools/dolm/utils/FileSystemIterator.java similarity index 63% rename from src/main/java/it/eomm/plugins/dolm/utils/FileSystemIterator.java rename to src/main/java/it/eomm/tools/dolm/utils/FileSystemIterator.java index 1793a24..0933640 100644 --- a/src/main/java/it/eomm/plugins/dolm/utils/FileSystemIterator.java +++ b/src/main/java/it/eomm/tools/dolm/utils/FileSystemIterator.java @@ -1,8 +1,9 @@ -package it.eomm.plugins.dolm.utils; +package it.eomm.tools.dolm.utils; import java.io.File; import java.io.FilenameFilter; import java.util.Iterator; +import java.util.NoSuchElementException; public class FileSystemIterator implements Iterator { @@ -13,6 +14,11 @@ public class FileSystemIterator implements Iterator { private File[] directoryContent; private int index; + /** + * Iterate all the files and directory in a dir path + * + * @param path to read + */ public FileSystemIterator(String path) { super(); this.path = path; @@ -20,6 +26,9 @@ public FileSystemIterator(String path) { this.directoryContent = null; } + /** + * Read the directory using File.listFiles + */ private void openDirectory() { // if is already open don't read if (this.directoryContent != null) { @@ -28,9 +37,8 @@ private void openDirectory() { File dir = new File(path); - // TODO - // if (!dir.isDirectory()) - // throw new IOException(path + " isn't a directoryContent"); + if (!dir.isDirectory()) + throw new IllegalStateException(path + " isn't a directory"); this.directoryContent = dir.listFiles(filter); @@ -40,23 +48,33 @@ private void openDirectory() { } } + /** + * @see Iterator#hasNext() + */ @Override public boolean hasNext() { openDirectory(); return index < directoryContent.length; } + /** + * @see Iterator#next() + * @throws IllegalStateException if the path is not a directory + */ @Override public File next() { if (!hasNext()) { - return null; + throw new NoSuchElementException(); } return directoryContent[index++]; } + /** + * @see Iterator#remove() + */ @Override public void remove() { - // TODO NOT IMPLEMENT YET + throw new UnsupportedOperationException("remove"); } public String getPath() { @@ -67,6 +85,9 @@ public FilenameFilter getFilter() { return filter; } + /** + * @param filter an optional filter to apply before iterate the directory + */ public void setFilter(FilenameFilter filter) { this.filter = filter; } diff --git a/src/test/java/it/eomm/plugins/dolm/test/DolmTest.java b/src/test/java/it/eomm/tools/dolm/test/DolmTest.java similarity index 97% rename from src/test/java/it/eomm/plugins/dolm/test/DolmTest.java rename to src/test/java/it/eomm/tools/dolm/test/DolmTest.java index 4e8f0c3..c624350 100644 --- a/src/test/java/it/eomm/plugins/dolm/test/DolmTest.java +++ b/src/test/java/it/eomm/tools/dolm/test/DolmTest.java @@ -1,6 +1,6 @@ -package it.eomm.plugins.dolm.test; +package it.eomm.tools.dolm.test; -import it.eomm.plugins.dolm.IDolm; +import it.eomm.tools.dolm.IDolm; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import java.io.File; @@ -89,7 +89,7 @@ public void testEmptySourceDirectory() throws Exception { IDolm mojo = getDolmMojo(); mojo.setSourcePath(sourceDir + "/empty"); mojo.setOutputPath(outputDir); - mojo.setFilter("*"); + mojo.setFilter("\\\\*"); mojo.setFilenamePatternOutput("%1$s-%2$s.%3$s"); mojo.execute(); // no errors expected diff --git a/src/test/resources/pom-test.xml b/src/test/resources/pom-test.xml index 6bdbf62..713e3cf 100644 --- a/src/test/resources/pom-test.xml +++ b/src/test/resources/pom-test.xml @@ -19,7 +19,7 @@ - it.eomm.plugins + it.eomm.tools dolm-maven-plugin