Skip to content

Commit

Permalink
LPS-26987 Allow user to override settings via command line
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchandotcom committed Apr 26, 2012
1 parent 56d3065 commit 9872fe8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
4 changes: 2 additions & 2 deletions build-common.xml
Expand Up @@ -360,10 +360,10 @@ Please set the environment variable ANT_OPTS to the recommended value of
newenvironment="true"
>
<jvmarg value="-Xmx512m" />
<arg value="javadoc.base.dir=${basedir}" />
<arg value="javadoc.init=${init}" />
<arg value="javadoc.input.dir=${input.dir}" />
<arg value="javadoc.limit=${limit}" />
<arg value="javadoc.output.file.prefix=javadocs" />
<arg value="javadoc.output.file.prefix=${output.file.prefix}" />
<arg value="javadoc.update=${update}" />
</java>
</target>
Expand Down
35 changes: 23 additions & 12 deletions portal-impl/src/com/liferay/portal/tools/JavadocFormatter.java
Expand Up @@ -77,21 +77,32 @@ public static void main(String[] args) {
public JavadocFormatter(String[] args) throws Exception {
Map<String, String> arguments = ArgumentsUtil.parseArguments(args);

_basedir = arguments.get("javadoc.base.dir");

if (!_basedir.endsWith("/")) {
_basedir += "/";
}

String init = arguments.get("javadoc.init");

if (Validator.isNotNull(init) && !init.startsWith("$")) {
_initializeMissingJavadocs = GetterUtil.getBoolean(init);
}

_inputDir = GetterUtil.getString(arguments.get("javadoc.input.dir"));

if (_inputDir.startsWith("$")) {
_inputDir = "./";
}

if (!_inputDir.endsWith("/")) {
_inputDir += "/";
}

System.out.println("Input directory is " + _inputDir);

String limit = arguments.get("javadoc.limit");

_outputFilePrefix = arguments.get("javadoc.output.file.prefix");
_outputFilePrefix = GetterUtil.getString(
arguments.get("javadoc.output.file.prefix"));

if (_outputFilePrefix.startsWith("$")) {
_outputFilePrefix = "javadocs";
}

String update = arguments.get("javadoc.update");

Expand All @@ -101,7 +112,7 @@ public JavadocFormatter(String[] args) throws Exception {

DirectoryScanner directoryScanner = new DirectoryScanner();

directoryScanner.setBasedir(_basedir);
directoryScanner.setBasedir(_inputDir);
directoryScanner.setExcludes(
new String[] {"**\\classes\\**", "**\\portal-client\\**"});

Expand Down Expand Up @@ -654,7 +665,7 @@ private void _detachUnnecessaryTypes(Element rootElement) {
}

private void _format(String fileName) throws Exception {
InputStream inputStream = new FileInputStream(_basedir + fileName);
InputStream inputStream = new FileInputStream(_inputDir + fileName);

byte[] bytes = new byte[inputStream.available()];

Expand Down Expand Up @@ -934,7 +945,7 @@ private Document _getJavadocDocument(JavaClass javaClass) throws Exception {
}

private Tuple _getJavadocsXmlTuple(String fileName) throws Exception {
File file = new File(fileName);
File file = new File(_inputDir + fileName);

String absolutePath = file.getAbsolutePath();

Expand Down Expand Up @@ -1519,7 +1530,7 @@ private void _updateJavaFromDocument(
String formattedContent = sb.toString().trim();

if (!originalContent.equals(formattedContent)) {
File file = new File(_basedir + fileName);
File file = new File(_inputDir + fileName);

_fileUtil.write(file, formattedContent.getBytes(StringPool.UTF8));

Expand Down Expand Up @@ -1571,8 +1582,8 @@ private String _wrapText(String text, String indent) {

private static SAXReaderImpl _saxReaderUtil = SAXReaderImpl.getInstance();

private String _basedir;
private boolean _initializeMissingJavadocs;
private String _inputDir;
private Map<String, Tuple> _javadocxXmlTuples =
new HashMap<String, Tuple>();
private String _outputFilePrefix;
Expand Down

0 comments on commit 9872fe8

Please sign in to comment.