
org.geomajas.maven.ExtractSourcePlugin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geomajas-maven-plugin Show documentation
Show all versions of geomajas-maven-plugin Show documentation
Geomajas maven plugin, used for extracting documentation extracts.
/*
* This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
*
* Copyright 2008-2015 Geosparc nv, http://www.geosparc.com/, Belgium.
*
* The program is available in open source according to the GNU Affero
* General Public License. All contributions in this program are covered
* by the Geomajas Contributors License Agreement. For full licensing
* details, see LICENSE.txt in the project root.
*/
package org.geomajas.maven;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
/**
* Maven plugin to extract excerpts from source files for inclusion in docbook documents.
*
* It scans all files in the given directory tree looking for the begin pattern and extracts the content starting from
* the next line, until (excluding) a line that contains the end comment.
*
* Some sanitization is done on the source, like replacing all tab characters by four spaces and removing the left
* margin.
*
* @author Joachim Van der Auwera
* @goal extract
* @description extract source excepts for xi:include in docbook
* @inherited false
*/
public class ExtractSourcePlugin extends AbstractMojo {
private static final String START_JAVA_ANNOTATION = "// @extract-start";
private static final String END_JAVA_ANNOTATION = "// @extract-end";
private static final String START_XML_ANNOTATION = "")) {
caption = caption.substring(0, caption.length() - 3).trim();
}
caption = caption.replace("&", "&");
caption = caption.replace("<", "<");
caption = caption.replace(">", ">");
File targetFile = new File(destinationDir, filename + ".xml");
BufferedWriter writer = new BufferedWriter(new FileWriter(targetFile));
writer.write("\n");
writer.write("\n");
writer.write("");
writer.write(caption);
writer.write(" \n");
writer.write("\n");
writer.write(" \n");
writer.write(" \n");
writer.flush();
writer.close();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy