doh, patches with diff -u
Nathan Coast wrote:
> Hi,
>
> latest version of the Jrefactory integration after feedback from maven-dev.
>
> all modified files are as patch files. All new files are for
> jakarta-turbine-maven/src/java/org/apache/maven/sourcedef/
>
> jrefactory.jar can be obtained from here and needs placing in lib.repo
> http://prdownloads.sourceforge.net/jrefactory/jrefactory-2.6.36-binary.zip
>
> FYI, running the maven:pretty-print target reduces checksource errors
> from 5K to 1K.
>
> Outstanding issues:
>
> when methods have static and final modifiers, Jrefactory orders them in
> a way that generates a checksource error. bug has been logged with
> jrefactory
>
> What should the default brace location be? turbine-style or sun-style?
>
> Should we be autogenerating javadoc? whilst reduces checkstyle errors,
> doesn't neccessarily improve the code?
>
> Should we autogenerate @author tags? If a file is missing the @author
> tag, the user who runs the pretty-print task will have their username
> inserted as the author. Only a problem if there is a significant number
> of files missing the @author tag.
>
> Cheers
> Nathan
>
>
> ------------------------------------------------------------------------
>
> Index: jakarta-turbine-maven/build.xml
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-maven/build.xml,v
> retrieving revision 1.37
> diff -r1.37 build.xml
> 149a150,153
>
>>
>> <target name="maven:pretty-print">
>> <ant antfile="${maven.home}/plugins/core/build.xml" target="pretty-print"/>
>> </target>
>>
>>
>>------------------------------------------------------------------------
>>
>>Index: jakarta-turbine-maven/src/templates/build/plugins/core/build.xml
>>===================================================================
>>RCS file:
>/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/core/build.xml,v
>>retrieving revision 1.4
>>diff -r1.4 build.xml
>>331a332,374
>>
>>> <!-- ================================================================== -->
>>> <!-- JRefactory Pretty Print -->
>>> <!-- ================================================================== -->
>>>
>>> <target
>>> name="pretty-print"
>>> depends="local-init, env"
>>> description="modify code according to maven source definition">
>>>
>>> <taskdef
>>> name="prettyprintconfig"
>>> classname="org.apache.maven.sourcedef.PrettyPrintConfigTask">
>>> <classpath refid="maven-classpath"/>
>>> </taskdef>
>>>
>>> <prettyprintconfig/>
>>>
>>> <taskdef name="filesetfrompath"
>>> classname="org.apache.maven.ant.FileSetFromPath">
>>> <classpath>
>>> <path refid="maven-classpath"/>
>>> </classpath>
>>> </taskdef>
>>>
>>> <filesetfrompath pathid="maven.src.set"
>>> filesetid="maven.sourceDirectories.fileset"
>>> includes="${maven.jrefactory.includes}"
>>> excludes="${maven.jrefactory.excludes}"/>
>>>
>>> <taskdef
>>> name="prettyprint"
>>> classname="org.acm.seguin.ant.Pretty">
>>> <classpath refid="maven-classpath"/>
>>> </taskdef>
>>>
>>> <prettyprint settingsDir="${maven.build.dir}">
>>> <fileset refid="maven.sourceDirectories.fileset" />
>>> </prettyprint>
>>>
>>> </target>
>>>
>>>
>>341a385,391
>>
>>> <taskdef
>>> name="checkstyleconfig"
>>> classname="org.apache.maven.sourcedef.CheckStyleConfigTask">
>>> <classpath refid="maven-classpath"/>
>>> </taskdef>
>>>
>>>
>>366,403c416,420
>>< <checkstyle
>>< lcurlyType="${maven.checkstyle.lcurly.type}"
>>< lcurlyMethod="${maven.checkstyle.lcurly.method}"
>>< lcurlyOther="${maven.checkstyle.lcurly.other}"
>>< rcurly="${maven.checkstyle.rcurly}"
>>< parenPad="${maven.checkstyle.paren.pad}"
>>< allowTabs="${maven.checkstyle.allow.tabs}"
>>< allowProtected="${maven.checkstyle.allow.protected}"
>>< allowPackage="${maven.checkstyle.allow.package}"
>>< allowNoAuthor="${maven.checkstyle.allow.no.author}"
>>< maxLineLen="${maven.checkstyle.max.line.len}"
>>< tabWidth="${maven.checkstyle.tab.width}"
>>< ignoreLineLengthPattern="${maven.checkstyle.ignore.line.len.pattern}"
>>< maxMethodLen="${maven.checkstyle.max.method.len}"
>>< maxConstructorLen="${maven.checkstyle.max.constructor.len}"
>>< maxFileLen="${maven.checkstyle.max.file.len}"
>>< ignoreImportLen="${maven.checkstyle.ignore.import.len}"
>>< memberPattern="${maven.checkstyle.member.pattern}"
>>< publicMemberPattern="${maven.checkstyle.public.member.pattern}"
>>< paramPattern="${maven.checkstyle.param.pattern}"
>>< constPattern="${maven.checkstyle.const.pattern}"
>>< staticPattern="${maven.checkstyle.static.pattern}"
>>< typePattern="${maven.checkstyle.type.pattern}"
>>< methodPattern="${maven.checkstyle.method.pattern}"
>>< localVarPattern="${maven.checkstyle.local.var.pattern}"
>>< headerFile="${maven.checkstyle.header.file}"
>>< headerLinesRegexp="${maven.checkstyle.header.lines.regexp}"
>>< headerIgnoreLine="${maven.checkstyle.header.ignore.line}"
>>< javadocScope="${maven.checkstyle.javadoc.scope}"
>>< requirePackageHtml="${maven.checkstyle.require.package.html}"
>>< ignoreImports="${maven.checkstyle.ignore.imports}"
>>< illegalImports="${maven.checkstyle.illegal.imports}"
>>< ignoreWhitespace="${maven.checkstyle.ignore.whitespace}"
>>< ignoreCastWhitespace="${maven.checkstyle.ignore.cast.whitespace}"
>>< ignoreBraces="${maven.checkstyle.ignore.braces}"
>>< ignorePublicInInterface="${maven.checkstyle.ignore.public.in.interface}"
>>< failOnViolation="${maven.checkstyle.fail.on.violation}"
>>< cacheFile="${maven.checkstyle.cache.file}" >
>>---
>>
>>> <checkstyleconfig/>
>>>
>>> <checkstyle
>>> properties="${maven.checkstyle.dir}/CheckStyleConfig.properties"
>>> failOnViolation="${maven.checkstyle.fail.on.violation}">
>>>
>>405,406c422,423
>>< <formatter type="xml" toFile="${maven.build.dir}/checkstyle-raw-report.xml"/>
>>< <formatter type="plain"
>toFile="${maven.build.dir}/checkstyle-raw-report.txt"/>
>>---
>>
>>> <formatter type="xml"
>toFile="${maven.checkstyle.dir}/checkstyle-raw-report.xml"/>
>>> <formatter type="plain"
>toFile="${maven.checkstyle.dir}/checkstyle-raw-report.txt"/>
>>>
>>413,414c430,431
>>< in="${maven.build.dir}/checkstyle-raw-report.xml"
>>< out="${maven.gen.docs}/checkstyle-report.xml">
>>---
>>
>>> in="${maven.checkstyle.dir}/checkstyle-raw-report.xml"
>>> out="${maven.checkstyle.dir}/checkstyle-report.xml">
>>>
>>>
>>>------------------------------------------------------------------------
>>>
>>>Index: jakarta-turbine-maven/src/templates/build/plugins/core/default.properties
>>>===================================================================
>>>RCS file:
>/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/core/default.properties,v
>>>retrieving revision 1.4
>>>diff -r1.4 default.properties
>>>77a78,90
>>>
>>>># source definition properties. if not set, default values below are
>>>># set by org.apache.maven.sourcedef.SourceDefinition
>>>>#
>>>>
>>>>#maven.sourcedef.class.brace.style=PASCAL
>>>>#maven.sourcedef.method.brace.style=PASCAL
>>>>#maven.sourcedef.block.brace.style=PASCAL
>>>>#maven.sourcedef.keyword.location.right.brace=alone
>>>>#maven.sourcedef.max.line.len=80
>>>>#maven.sourcedef.header.file=LICENSE.txt
>>>>#maven.sourcedef.allow.tabs=false
>>>>
>>>>#
>>>>
>>>80a94
>>>
>>>>maven.checkstyle.dir=${maven.build.dir}/checkstyle
>>>>
>>>83,86d96
>>>< maven.checkstyle.lcurly.type = nl
>>>< maven.checkstyle.lcurly.method = nl
>>>< maven.checkstyle.lcurly.other = nl
>>>< maven.checkstyle.rcurly = alone
>>>88d97
>>>< maven.checkstyle.allow.tabs = false
>>>92d100
>>>< maven.checkstyle.max.line.len = 80
>>>107d114
>>>< maven.checkstyle.header.file = LICENSE.txt
>>>109c116
>>>< maven.checkstyle.header.ignore.line = 1,6
>>>---
>>>
>>>>maven.checkstyle.header.ignore.line=
>>>>
>>>119c126,213
>>>< maven.checkstyle.cache.file = ${maven.build.dir}/checkstyle-cachefile
>>>---
>>>
>>>>maven.checkstyle.cache.file = ${maven.checkstyle.dir}/checkstyle-cachefile
>>>>
>>>>#
>>>># jrefactroy properties
>>>>#
>>>>
>>>>maven.jrefactory.includes=**/*.java
>>>>maven.jrefactory.excludes=
>>>>maven.jrefactory.version=3.8
>>>>maven.jrefactory.indent=4
>>>>maven.jrefactory.indent.char=space
>>>>maven.jrefactory.expr.space=false
>>>>maven.jrefactory.lines.between=2
>>>>maven.jrefactory.cast.space=true
>>>>maven.jrefactory.cast.force.nospace=false
>>>>maven.jrefactory.surprise.return=double
>>>>maven.jrefactory.throws.newline=false
>>>>maven.jrefactory.field.name.indent=-1
>>>>maven.jrefactory.end.line=CRNL
>>>>maven.jrefactory.variable.spacing=single
>>>>maven.jrefactory.dynamic.variable.spacing=1
>>>>maven.jrefactory.variable.align.with.block=false
>>>>maven.jrefactory.case.indent=4
>>>>maven.jrefactory.keyword.space=true
>>>>maven.jrefactory.insert.space.around.local.variables=false
>>>>maven.jrefactory.lines.after.package=1
>>>>maven.jrefactory.maintain.newlines.around.imports=true
>>>>maven.jrefactory.lines.before.class=0
>>>>maven.jrefactory.indent.in.initializer=false
>>>>maven.jrefactory.bang.space=false
>>>>maven.jrefactory.method.space=false
>>>>maven.jrefactory.cast.inside.space=false
>>>>maven.jrefactory.space.around.ops=true
>>>>maven.jrefactory.force.block=true
>>>>maven.jrefactory.empty.block.single.line=true
>>>>maven.jrefactory.remove.excess.blocks=false
>>>>maven.jrefactory.singleline.comment.ownline=true
>>>>maven.jrefactory.singleline.comment.absoluteindent=0
>>>>maven.jrefactory.singleline.comment.incrementalindent=0
>>>>maven.jrefactory.singleline.comment.indentstyle.shared=incremental
>>>>maven.jrefactory.singleline.comment.indentstyle.ownline=code
>>>>maven.jrefactory.c.style.format=align.star
>>>>maven.jrefactory.c.style.indent=2
>>>>maven.jrefactory.method.minimum=all
>>>>maven.jrefactory.field.minimum=protected
>>>>maven.jrefactory.class.minimum=all
>>>>maven.jrefactory.javadoc.star=2
>>>>maven.jrefactory.javadoc.wordwrap.min=40
>>>>maven.jrefactory.space.before.javadoc=true
>>>>maven.jrefactory.javadoc.id.lineup=true
>>>>maven.jrefactory.javadoc.indent=2
>>>>maven.jrefactory.reformat.comments=true
>>>>maven.jrefactory.exception.tag.name=@exception
>>>>maven.jrefactory.document.nested.classes=true
>>>>maven.jrefactory.allow.singleline.javadoc=false
>>>>maven.jrefactory.keep.all.javadoc=false
>>>>maven.jrefactory.class.descr=Description of the Class
>>>>maven.jrefactory.interface.descr=Description of the Interface
>>>>maven.jrefactory.constructor.descr=Constructor for the {0} object
>>>>maven.jrefactory.method.descr=Description of the Method
>>>>maven.jrefactory.getter.descr=Gets the {3} attribute of the {1} {2}
>>>>maven.jrefactory.getter.return.descr=The {3} value
>>>>maven.jrefactory.setter.descr=Sets the {3} attribute of the {1} {2}
>>>>maven.jrefactory.setter.param.descr=The new {3} value
>>>>maven.jrefactory.field.descr=Description of the Field
>>>>maven.jrefactory.run.descr=Main processing method for the {1} {2}
>>>>maven.jrefactory.main.descr=The main program for the {1} {2}
>>>>maven.jrefactory.main.param.descr=The command line arguments
>>>>maven.jrefactory.adder.descr=Adds a feature to the {0} attribute of the {1} {2}
>>>>maven.jrefactory.adder.param.descr=The feature to be added to the {0} attribute
>>>>maven.jrefactory.junit.setUp.descr=The JUnit setup method
>>>>maven.jrefactory.junit.test.descr=A unit test for JUnit
>>>>maven.jrefactory.junit.tearDown.descr=The teardown method for JUnit
>>>>maven.jrefactory.junit.suite.descr=A unit test suite for JUnit
>>>>maven.jrefactory.junit.suite.return.descr=The test suite
>>>>maven.jrefactory.author.descr={0}
>>>>maven.jrefactory.created.descr={1}
>>>>maven.jrefactory.param.descr=Description of the Parameter
>>>>maven.jrefactory.return.descr=Description of the Return Value
>>>>maven.jrefactory.exception.descr=Description of the Exception
>>>>maven.jrefactory.class.tags=created
>>>>maven.jrefactory.method.tags=param,return,exception
>>>>maven.jrefactory.field.tags=
>>>>maven.jrefactory.char.stream.type=1
>>>>maven.jrefactory.pretty.printer.backup.ext=
>>>>maven.jrefactory.sort.top=false
>>>>maven.jrefactory.import.sort.important=
>>>>maven.jrefactory.import.sort.neighbourhood=0
>>>>
>>>>
>>>>------------------------------------------------------------------------
>>>>
>>>>Index: jakarta-turbine-maven/jars.list
>>>>===================================================================
>>>>RCS file: /home/cvspublic/jakarta-turbine-maven/jars.list,v
>>>>retrieving revision 1.9
>>>>diff -r1.9 jars.list
>>>>41a42
>>>>
>>>>>jrefactory.jar
>>>>>
>>>>>
>>>>>------------------------------------------------------------------------
>>>>>
>>>>>Index: jakarta-turbine-maven/project.xml
>>>>>===================================================================
>>>>>RCS file: /home/cvspublic/jakarta-turbine-maven/project.xml,v
>>>>>retrieving revision 1.80
>>>>>diff -r1.80 project.xml
>>>>>329a330,338
>>>>>
>>>>>> <dependency>
>>>>>> <name>jrefactory</name>
>>>>>> <type>required</type>
>>>>>> <version>2.6.36</version>
>>>>>> <jar>jrefactory.jar</jar>
>>>>>> <url>http://jrefactory.sourceforge.net/chrissoft.html</url>
>>>>>> </dependency>
>>>>>>
>>>>>>
>>>>>>
>>>>>>------------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>
>>>>>>/* ====================================================================
>>>>>> * The Apache Software License, Version 1.1
>>>>>> *
>>>>>> * Copyright (c) 2001 The Apache Software Foundation. All rights
>>>>>> * reserved.
>>>>>> *
>>>>>> * Redistribution and use in source and binary forms, with or without
>>>>>> * modification, are permitted provided that the following conditions
>>>>>> * are met:
>>>>>> *
>>>>>> * 1. Redistributions of source code must retain the above copyright
>>>>>> * notice, this list of conditions and the following disclaimer.
>>>>>> *
>>>>>> * 2. Redistributions in binary form must reproduce the above copyright
>>>>>> * notice, this list of conditions and the following disclaimer in
>>>>>> * the documentation and/or other materials provided with the
>>>>>> * distribution.
>>>>>> *
>>>>>> * 3. The end-user documentation included with the redistribution,
>>>>>> * if any, must include the following acknowledgment:
>>>>>> * "This product includes software developed by the
>>>>>> * Apache Software Foundation (http://www.apache.org/)."
>>>>>> * Alternately, this acknowledgment may appear in the software itself,
>>>>>> * if and wherever such third-party acknowledgments normally appear.
>>>>>> *
>>>>>> * 4. The names "Apache" and "Apache Software Foundation" and
>>>>>> * "Apache Maven" must not be used to endorse or promote products
>>>>>> * derived from this software without prior written permission. For
>>>>>> * written permission, please contact [EMAIL PROTECTED]
>>>>>> *
>>>>>> * 5. Products derived from this software may not be called "Apache",
>>>>>> * "Apache Maven", nor may "Apache" appear in their name, without
>>>>>> * prior written permission of the Apache Software Foundation.
>>>>>> *
>>>>>> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>>>>>> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>>>>>> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>>>>>> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>>>>>> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>>>>>> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>>>>>> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>>>>>> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>>>>>> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>>>>>> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>>>>>> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>>>>>> * SUCH DAMAGE.
>>>>>> * ====================================================================
>>>>>> *
>>>>>> * This software consists of voluntary contributions made by many
>>>>>> * individuals on behalf of the Apache Software Foundation. For more
>>>>>> * information on the Apache Software Foundation, please see
>>>>>> * <http://www.apache.org/>.
>>>>>> *
>>>>>> * ====================================================================
>>>>>> */
>>>>>>package org.apache.maven.sourcedef;
>>>>>>
>>>>>>import java.io.File;
>>>>>>import com.puppycrawl.tools.checkstyle.CheckStyleTask;
>>>>>>import org.apache.tools.ant.BuildException;
>>>>>>import org.apache.tools.ant.Task;
>>>>>>import org.apache.tools.ant.Project;
>>>>>>import java.io.FileOutputStream;
>>>>>>import java.io.IOException;
>>>>>>import java.util.Hashtable;
>>>>>>import java.util.Properties;
>>>>>>import java.util.Iterator;
>>>>>>
>>>>>>/**
>>>>>> * task responsible for writing the checkstyle config file by combining
>>>>>> * properties with these prefixes maven.sourcedef and maven.checkstyle. generic
>>>>>> * maven.sourcedef properties are converted to checkstyle counterpart. For
>>>>>> * allowed properties and conversions see the {@link org.apache.maven.sourcedef
>>>>>> * package description}.
>>>>>> *
>>>>>> * @created 28 May 2002
>>>>>> * @author Nathan Coast ([EMAIL PROTECTED])
>>>>>> */
>>>>>>public class CheckStyleConfigTask extends Task {
>>>>>>
>>>>>> /**
>>>>>> * checkstyle property name for the class brace style property
>>>>>> */
>>>>>> private final static String CLASS_BRACE_STYLE_KEY = "checkstyle.lcurly.type";
>>>>>>
>>>>>> /**
>>>>>> * checkstyle property name for the method brace style property
>>>>>> */
>>>>>> private final static String METHOD_BRACE_STYLE_KEY =
>"checkstyle.lcurly.method";
>>>>>>
>>>>>> /**
>>>>>> * checkstyle property name for the all other brace styles
>>>>>> */
>>>>>> private final static String OTHER_BRACE_STYLE_KEY =
>"checkstyle.lcurly.other";
>>>>>>
>>>>>> /**
>>>>>> * checkstyle property name for the location of keyword relative to right
>>>>>> * brace.
>>>>>> */
>>>>>> private final static String RIGHT_BRACE_KEYWORD_LOCATION_KEY =
>>>>>> "checkstyle.rcurly";
>>>>>>
>>>>>> /**
>>>>>> * checkstyle property name for allow tabs property
>>>>>> */
>>>>>> private final static String ALLOW_TABS_KEY = "checkstyle.allow.tabs";
>>>>>>
>>>>>> /**
>>>>>> * checkstyle property name for max line lenght property
>>>>>> */
>>>>>> private final static String MAX_LINE_LENGTH_KEY = "checkstyle.maxlinelen";
>>>>>>
>>>>>> /**
>>>>>> * checkstyle property name for header file property
>>>>>> */
>>>>>> private final static String HEADER_FILE_KEY = "checkstyle.header.file";
>>>>>>
>>>>>> /**
>>>>>> * eol left brace style value
>>>>>> */
>>>>>> private final static String LEFT_CURLY_EOL = "eol";
>>>>>>
>>>>>> /**
>>>>>> * nl left brace style value
>>>>>> */
>>>>>> private final static String LEFT_CURLY_NL = "nl";
>>>>>>
>>>>>> /**
>>>>>> * name of the generated checkstyle config file
>>>>>> */
>>>>>> private final static String CONFIG_FILENAME = "CheckStyleConfig.properties";
>>>>>>
>>>>>> /**
>>>>>> * prefix for checkstyle properties in default.properties
>>>>>> */
>>>>>> private final static String CHECKSTYLE_PROP_PREFIX = "maven.checkstyle.";
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * execute method to combine the maven.checkstyle properties with converted
>>>>>> * maven.sourcedef properties and write them to
>>>>>> * ${maven.checkstyle.dir}/CheckStyleConfig.properties
>>>>>> *
>>>>>> * @exception BuildException Description of the Exception
>>>>>> */
>>>>>> public void execute() throws BuildException {
>>>>>>
>>>>>> Project project = getProject();
>>>>>>
>>>>>> Hashtable props = project.getProperties();
>>>>>>
>>>>>> String checkstyleDirStr = (String) props.get("maven.checkstyle.dir");
>>>>>> File checkstyleDir = new File(checkstyleDirStr);
>>>>>> if (!checkstyleDir.exists()) {
>>>>>> if (!checkstyleDir.mkdir()) {
>>>>>> throw new BuildException("unable to create checkstyle directory:
>"
>>>>>> + checkstyleDir);
>>>>>> }
>>>>>> }
>>>>>> File configFile = new File(checkstyleDir, CONFIG_FILENAME);
>>>>>> Properties config = new Properties();
>>>>>> Iterator it = props.keySet().iterator();
>>>>>> while (it.hasNext()) {
>>>>>> String key = (String) it.next();
>>>>>> if (key.startsWith(CHECKSTYLE_PROP_PREFIX)) {
>>>>>> config.put(key.substring(6), props.get(key));
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> SourceDefinition.setProjectProperties(getProject().getProperties());
>>>>>> String classBraceStyle = SourceDefinition.getClassBraceStyle();
>>>>>> classBraceStyle = convertLeftBraceType(classBraceStyle);
>>>>>> config.put(CLASS_BRACE_STYLE_KEY, classBraceStyle);
>>>>>>
>>>>>> String methodBraceStyle = SourceDefinition.getMethodBraceStyle();
>>>>>> methodBraceStyle = convertLeftBraceType(methodBraceStyle);
>>>>>> config.put(METHOD_BRACE_STYLE_KEY, methodBraceStyle);
>>>>>>
>>>>>> String blockBraceStyle = SourceDefinition.getBlockBraceStyle();
>>>>>> blockBraceStyle = convertLeftBraceType(blockBraceStyle);
>>>>>> config.put(OTHER_BRACE_STYLE_KEY, blockBraceStyle);
>>>>>>
>>>>>> config.put(RIGHT_BRACE_KEYWORD_LOCATION_KEY,
>>>>>> SourceDefinition.getKeywordLocationRightBrace());
>>>>>>
>>>>>> config.put(ALLOW_TABS_KEY, "" + SourceDefinition.getAllowTabs());
>>>>>>
>>>>>> config.put(MAX_LINE_LENGTH_KEY, "" +
>SourceDefinition.getMaxLineLength());
>>>>>>
>>>>>> File headerFile = SourceDefinition.getHeaderFile();
>>>>>> if (headerFile.exists() && headerFile.canRead() && headerFile.isFile()) {
>>>>>> config.put(HEADER_FILE_KEY, headerFile.toString());
>>>>>> }
>>>>>>
>>>>>> FileOutputStream fos = null;
>>>>>> try {
>>>>>> fos = new FileOutputStream(configFile);
>>>>>> config.store(fos, "this is a generated file do not edit");
>>>>>> } catch (IOException e) {
>>>>>> throw new BuildException(e);
>>>>>> } finally {
>>>>>> if (fos != null) {
>>>>>> try {
>>>>>> fos.close();
>>>>>> } catch (IOException e) {
>>>>>> e.printStackTrace();
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * utility to convert between maven.sourcedef properties and checkstyle.
>>>>>> * properties for the left brace style.
>>>>>> *
>>>>>> * @param type the maven.sourcedef property to convert
>>>>>> * @return the maven.sourcedef property converted to checkstyle
>>>>>> * property.
>>>>>> */
>>>>>> private static String convertLeftBraceType(String type) {
>>>>>>
>>>>>> String convertedType = null;
>>>>>> if (SourceDefinition.BRACE_STYLE_C.equals(type)) {
>>>>>> convertedType = LEFT_CURLY_EOL;
>>>>>> } else if (SourceDefinition.BRACE_STYLE_PASCAL.equals(type)) {
>>>>>> convertedType = LEFT_CURLY_NL;
>>>>>> } else {
>>>>>> throw new BuildException("Unknown left brace type " + type);
>>>>>> }
>>>>>> return convertedType;
>>>>>> }
>>>>>>}
>>>>>>
>>>>>>
>>>>>>------------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>
>>>>>>/* ====================================================================
>>>>>> * The Apache Software License, Version 1.1
>>>>>> *
>>>>>> * Copyright (c) 2001 The Apache Software Foundation. All rights
>>>>>> * reserved.
>>>>>> *
>>>>>> * Redistribution and use in source and binary forms, with or without
>>>>>> * modification, are permitted provided that the following conditions
>>>>>> * are met:
>>>>>> *
>>>>>> * 1. Redistributions of source code must retain the above copyright
>>>>>> * notice, this list of conditions and the following disclaimer.
>>>>>> *
>>>>>> * 2. Redistributions in binary form must reproduce the above copyright
>>>>>> * notice, this list of conditions and the following disclaimer in
>>>>>> * the documentation and/or other materials provided with the
>>>>>> * distribution.
>>>>>> *
>>>>>> * 3. The end-user documentation included with the redistribution,
>>>>>> * if any, must include the following acknowledgment:
>>>>>> * "This product includes software developed by the
>>>>>> * Apache Software Foundation (http://www.apache.org/)."
>>>>>> * Alternately, this acknowledgment may appear in the software itself,
>>>>>> * if and wherever such third-party acknowledgments normally appear.
>>>>>> *
>>>>>> * 4. The names "Apache" and "Apache Software Foundation" and
>>>>>> * "Apache Maven" must not be used to endorse or promote products
>>>>>> * derived from this software without prior written permission. For
>>>>>> * written permission, please contact [EMAIL PROTECTED]
>>>>>> *
>>>>>> * 5. Products derived from this software may not be called "Apache",
>>>>>> * "Apache Maven", nor may "Apache" appear in their name, without
>>>>>> * prior written permission of the Apache Software Foundation.
>>>>>> *
>>>>>> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>>>>>> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>>>>>> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>>>>>> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>>>>>> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>>>>>> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>>>>>> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>>>>>> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>>>>>> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>>>>>> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>>>>>> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>>>>>> * SUCH DAMAGE.
>>>>>> * ====================================================================
>>>>>> *
>>>>>> * This software consists of voluntary contributions made by many
>>>>>> * individuals on behalf of the Apache Software Foundation. For more
>>>>>> * information on the Apache Software Foundation, please see
>>>>>> * <http://www.apache.org/>.
>>>>>> *
>>>>>> * ====================================================================
>>>>>> */
>>>>>>package org.apache.maven.sourcedef;
>>>>>>
>>>>>>import org.apache.tools.ant.Task;
>>>>>>import org.apache.tools.ant.BuildException;
>>>>>>import org.apache.tools.ant.Project;
>>>>>>import java.util.Properties;
>>>>>>import java.util.Iterator;
>>>>>>import java.util.Set;
>>>>>>import java.util.Hashtable;
>>>>>>import java.io.File;
>>>>>>import java.io.FileInputStream;
>>>>>>import java.io.FileOutputStream;
>>>>>>import java.io.IOException;
>>>>>>import java.io.BufferedReader;
>>>>>>import java.io.FileReader;
>>>>>>
>>>>>>/**
>>>>>> * task responsible for writing the Jrefactory pretty print config file by
>>>>>> * combining properties with these prefixes maven.sourcedef and
>>>>>> * maven.jrefactory. Generic maven.sourcedef properties are converted to their
>>>>>> * jrefactory counterparts. For allowed properties and conversions see the
>>>>>> * {@link org.apache.maven.sourcedef package description}.
>>>>>> *
>>>>>> * @created 28 May 2002
>>>>>> * @author Nathan Coast ([EMAIL PROTECTED])
>>>>>> */
>>>>>>public class PrettyPrintConfigTask extends Task {
>>>>>>
>>>>>> /**
>>>>>> * jrefactory property name for the catch start line property
>>>>>> */
>>>>>> private final static String CATCH_START_LINE = "catch.start.line";
>>>>>>
>>>>>> /**
>>>>>> * jrefactory property name for the else start line property
>>>>>> */
>>>>>> private final static String ELSE_START_LINE = "else.start.line";
>>>>>>
>>>>>> /**
>>>>>> * jrefactory property name for the block property
>>>>>> */
>>>>>> private final static String BLOCK_STYLE = "block.style";
>>>>>>
>>>>>> /**
>>>>>> * jrefactory property name for the method block style property
>>>>>> */
>>>>>> private final static String METHOD_BLOCK_STYLE = "method.block.style";
>>>>>>
>>>>>> /**
>>>>>> * jrefactory property name for the class block style property
>>>>>> */
>>>>>> private final static String CLASS_BLOCK_STYLE = "class.block.style";
>>>>>>
>>>>>> /**
>>>>>> * jrefactory property name for the javadoc wordwrap property
>>>>>> */
>>>>>> private final static String JAVADOC_WORDWRAP_MAX = "javadoc.wordwrap.max";
>>>>>>
>>>>>> /**
>>>>>> * allowed 'space' value for the indent char property
>>>>>> */
>>>>>> private final static String SPACE = "space";
>>>>>>
>>>>>> /**
>>>>>> * allowed 'tab' value for the indent char property
>>>>>> */
>>>>>> private final static String TAB = "tab";
>>>>>>
>>>>>> /**
>>>>>> * jrefactory property name for the indent char property
>>>>>> */
>>>>>> private final static String INDENT_CHAR = "indent.char";
>>>>>>
>>>>>> /**
>>>>>> * prefix for jrefactory specific propeties
>>>>>> */
>>>>>> private final static String JREFACTORY_PROP_PREFIX = "maven.jrefactory.";
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * execute method to combine the maven.jrefactory properties with converted
>>>>>> * maven.sourcedef properties and write them to the file
>>>>>> * ${maven.build.dir}/.Refactory/pretty.settings
>>>>>> *
>>>>>> * @exception BuildException Description of the Exception
>>>>>> */
>>>>>> public void execute() throws BuildException {
>>>>>>
>>>>>> Hashtable props = getProject().getProperties();
>>>>>>
>>>>>> SourceDefinition.setProjectProperties(props);
>>>>>>
>>>>>> Properties config = new Properties();
>>>>>> Iterator it = props.keySet().iterator();
>>>>>> while (it.hasNext()) {
>>>>>> String key = (String) it.next();
>>>>>> if (key.startsWith(JREFACTORY_PROP_PREFIX)) {
>>>>>> config.put(key.substring(JREFACTORY_PROP_PREFIX.length()),
>>>>>> props.get(key));
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> String buildDirStr = (String) props.get("maven.build.dir");
>>>>>> File buildDir = new File(buildDirStr);
>>>>>> File prettyDir = new File(buildDir, ".Refactory");
>>>>>> if (!prettyDir.exists()) {
>>>>>> if (!prettyDir.mkdir()) {
>>>>>> throw new BuildException(
>>>>>> "unable to create jrefactory pretty print config
>directory: "
>>>>>> + prettyDir);
>>>>>> }
>>>>>> }
>>>>>> File prettySettings = new File(prettyDir, "pretty.settings");
>>>>>>
>>>>>> if (prettySettings.exists()) {
>>>>>> prettySettings.delete();
>>>>>> }
>>>>>>
>>>>>> FileOutputStream fos = null;
>>>>>> try {
>>>>>>
>>>>>> String classBlockStyle = SourceDefinition.getClassBraceStyle();
>>>>>> config.put(CLASS_BLOCK_STYLE, classBlockStyle);
>>>>>>
>>>>>> String methodBlockStyle = SourceDefinition.getMethodBraceStyle();
>>>>>> config.put(METHOD_BLOCK_STYLE, methodBlockStyle);
>>>>>>
>>>>>> String blockStyle = SourceDefinition.getBlockBraceStyle();
>>>>>> config.put(BLOCK_STYLE, blockStyle);
>>>>>>
>>>>>> String keyLoc = SourceDefinition.getKeywordLocationRightBrace();
>>>>>> String catchStartLine = convertKeywordLocationRightBrace(keyLoc);
>>>>>> config.put(CATCH_START_LINE, catchStartLine);
>>>>>> config.put(ELSE_START_LINE, catchStartLine);
>>>>>>
>>>>>> File headerFile = SourceDefinition.getHeaderFile();
>>>>>> populateHeaderFile(headerFile, config);
>>>>>>
>>>>>> int javadocWordwrapMax = SourceDefinition.getMaxLineLength();
>>>>>> config.put(JAVADOC_WORDWRAP_MAX, "" + javadocWordwrapMax);
>>>>>>
>>>>>> boolean allowTabs = SourceDefinition.getAllowTabs();
>>>>>> String indentChar = convertAllowTabs(allowTabs);
>>>>>> config.put(INDENT_CHAR, indentChar);
>>>>>>
>>>>>> /*
>>>>>> * if(SourceDefinition.getFollowJlsOrder()){
>>>>>> *
>config.put("sort.1","Type(Field,Constructor,Method,NestedClass,NestedInterface,Initializer)");
>>>>>> * config.put("sort.2","Class(Instance,Static)");
>>>>>> * config.put("sort.3","Method(setter,getter,other)");
>>>>>> * config.put("sort.4","Final(top)");
>>>>>> * config.put("sort.5","Protection(public)");
>>>>>> * config.put("sort.6","Bean()");
>>>>>> * config.put("sort.7","Alphabetical()");
>>>>>> * config.put("sort.8","FieldInitializers()");
>>>>>> * }
>>>>>> */
>>>>>> //File tmpPrettyProps = new File("tmpPrettyProps.settings");
>>>>>> fos = new FileOutputStream(prettySettings);
>>>>>> config.store(fos, "this is a generated file do not edit");
>>>>>> } catch (IOException e) {
>>>>>> throw new BuildException(e);
>>>>>> } finally {
>>>>>> if (fos != null) {
>>>>>> try {
>>>>>> fos.close();
>>>>>> } catch (IOException e) {
>>>>>> e.printStackTrace();
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * method to convert property from
>maven.sourcedef.keyword.location.right.brace
>>>>>> * to jrefactory property values.
>>>>>> *
>>>>>> * @param location the maven.sourcdef property
>>>>>> * @return the property converted to a jrefactory property
>>>>>> */
>>>>>> private static String convertKeywordLocationRightBrace(String location) {
>>>>>> String convertedLocation = null;
>>>>>> if (SourceDefinition.KEYWORD_LOCATION_RIGHT_BRACE_SAME.equals(location))
>{
>>>>>> convertedLocation = "false";
>>>>>> } else if
>(SourceDefinition.KEYWORD_LOCATION_RIGHT_BRACE_ALONE.equals(location)) {
>>>>>> convertedLocation = "true";
>>>>>> } else {
>>>>>> throw new BuildException("Unrecognised keyword location " +
>location);
>>>>>> }
>>>>>> return convertedLocation;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * method to read the header file and populate the contents of the file
>>>>>> * into the properties using the property names 'header.[line_num]'
>>>>>> *
>>>>>> * @param headerFile the headerFile
>>>>>> * @param props the properties to load the header file into.
>>>>>> * @exception IOException Description of the Exception
>>>>>> */
>>>>>> private static void populateHeaderFile(File headerFile, Properties props)
>>>>>> throws IOException {
>>>>>>
>>>>>> FileReader fr = new FileReader(headerFile);
>>>>>> BufferedReader br = new BufferedReader(fr);
>>>>>>
>>>>>> String str = null;
>>>>>> int count = 0;
>>>>>> while ((str = br.readLine()) != null) {
>>>>>> count++;
>>>>>> String headerLine = "header." + count;
>>>>>> props.put(headerLine, str);
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * method to convert the maven.sourcedef.allow.tabs property to the
>>>>>> * appropriate jrefactory property
>>>>>> *
>>>>>> * @param allowTabs the maven.sourcedef.allow.tabs property
>>>>>> * @return allow tabs property converted to jrefactory property
>>>>>> */
>>>>>> private static String convertAllowTabs(boolean allowTabs) {
>>>>>> String indentChar = null;
>>>>>> if (allowTabs) {
>>>>>> indentChar = TAB;
>>>>>> } else {
>>>>>> indentChar = SPACE;
>>>>>> }
>>>>>> return indentChar;
>>>>>> }
>>>>>>}
>>>>>>
>>>>>>
>>>>>>------------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>
>>>>>>/* ====================================================================
>>>>>> * The Apache Software License, Version 1.1
>>>>>> *
>>>>>> * Copyright (c) 2001 The Apache Software Foundation. All rights
>>>>>> * reserved.
>>>>>> *
>>>>>> * Redistribution and use in source and binary forms, with or without
>>>>>> * modification, are permitted provided that the following conditions
>>>>>> * are met:
>>>>>> *
>>>>>> * 1. Redistributions of source code must retain the above copyright
>>>>>> * notice, this list of conditions and the following disclaimer.
>>>>>> *
>>>>>> * 2. Redistributions in binary form must reproduce the above copyright
>>>>>> * notice, this list of conditions and the following disclaimer in
>>>>>> * the documentation and/or other materials provided with the
>>>>>> * distribution.
>>>>>> *
>>>>>> * 3. The end-user documentation included with the redistribution,
>>>>>> * if any, must include the following acknowledgment:
>>>>>> * "This product includes software developed by the
>>>>>> * Apache Software Foundation (http://www.apache.org/)."
>>>>>> * Alternately, this acknowledgment may appear in the software itself,
>>>>>> * if and wherever such third-party acknowledgments normally appear.
>>>>>> *
>>>>>> * 4. The names "Apache" and "Apache Software Foundation" and
>>>>>> * "Apache Maven" must not be used to endorse or promote products
>>>>>> * derived from this software without prior written permission. For
>>>>>> * written permission, please contact [EMAIL PROTECTED]
>>>>>> *
>>>>>> * 5. Products derived from this software may not be called "Apache",
>>>>>> * "Apache Maven", nor may "Apache" appear in their name, without
>>>>>> * prior written permission of the Apache Software Foundation.
>>>>>> *
>>>>>> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>>>>>> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>>>>>> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>>>>>> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>>>>>> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>>>>>> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>>>>>> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>>>>>> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>>>>>> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>>>>>> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>>>>>> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>>>>>> * SUCH DAMAGE.
>>>>>> * ====================================================================
>>>>>> *
>>>>>> * This software consists of voluntary contributions made by many
>>>>>> * individuals on behalf of the Apache Software Foundation. For more
>>>>>> * information on the Apache Software Foundation, please see
>>>>>> * <http://www.apache.org/>.
>>>>>> *
>>>>>> * ====================================================================
>>>>>> */
>>>>>>package org.apache.maven.sourcedef;
>>>>>>
>>>>>>import java.io.File;
>>>>>>import java.util.Arrays;
>>>>>>import java.util.List;
>>>>>>import java.util.Hashtable;
>>>>>>import org.apache.tools.ant.BuildException;
>>>>>>
>>>>>>/**
>>>>>> * Utility class to provide access to the maven.sourcedef properties. If a
>>>>>> * property exisits in the project properties, it is against allowed values for
>>>>>> * that property (if there are any). If the property isn't set, a default is
>>>>>> * returned.
>>>>>> *
>>>>>> * @created 28 May 2002
>>>>>> * @author Nathan Coast ([EMAIL PROTECTED])
>>>>>> */
>>>>>>class SourceDefinition {
>>>>>>
>>>>>> /**
>>>>>> * value for 'C' brace style
>>>>>> */
>>>>>> public final static String BRACE_STYLE_C = "C";
>>>>>>
>>>>>> /**
>>>>>> * value for 'pascal' brace style
>>>>>> */
>>>>>> public final static String BRACE_STYLE_PASCAL = "PASCAL";
>>>>>>
>>>>>> /**
>>>>>> * allowed brace styles 'C' or 'PASCAL'
>>>>>> */
>>>>>> private final static String[] BRACE_STYLE_ALLOWED = {BRACE_STYLE_C,
>>>>>> BRACE_STYLE_PASCAL};
>>>>>>
>>>>>> /**
>>>>>> * property name for block brace style
>>>>>> */
>>>>>> private final static String BLOCK_BRACE_STYLE_KEY =
>>>>>> "maven.sourcedef.block.brace.style";
>>>>>>
>>>>>> /**
>>>>>> * default value for block brace style
>>>>>> */
>>>>>> private final static String BLOCK_BRACE_STYLE_DEFAULT = BRACE_STYLE_C;
>>>>>>
>>>>>> private final static String METHOD_BRACE_STYLE_KEY =
>>>>>> "maven.sourcedef.method.brace.style";
>>>>>>
>>>>>> private final static String METHOD_BRACE_STYLE_DEFAULT = BRACE_STYLE_C;
>>>>>>
>>>>>> private final static String CLASS_BRACE_STYLE_KEY =
>>>>>> "maven.sourcedef.class.brace.style";
>>>>>>
>>>>>> private final static String CLASS_BRACE_STYLE_DEFAULT = BRACE_STYLE_C;
>>>>>>
>>>>>> /**
>>>>>> * Description of the Field
>>>>>> */
>>>>>> public final static String KEYWORD_LOCATION_RIGHT_BRACE_SAME = "same";
>>>>>>
>>>>>> /**
>>>>>> * Description of the Field
>>>>>> */
>>>>>> public final static String KEYWORD_LOCATION_RIGHT_BRACE_ALONE = "alone";
>>>>>>
>>>>>> private final static String[] KEYWORD_LOCATION_RIGHT_BRACE_ALLOWED =
>>>>>> {KEYWORD_LOCATION_RIGHT_BRACE_SAME,
>>>>>> KEYWORD_LOCATION_RIGHT_BRACE_ALONE};
>>>>>>
>>>>>> private final static String KEYWORD_LOCATION_RIGHT_BRACE_KEY =
>>>>>> "maven.sourcedef.keyword.location.right.brace";
>>>>>>
>>>>>> private final static String KEYWORD_LOCATION_RIGHT_BRACE_DEFAULT =
>>>>>> KEYWORD_LOCATION_RIGHT_BRACE_SAME;
>>>>>>
>>>>>> private final static String MAX_LINE_LENGTH_KEY =
>"maven.sourcedef.max.line.len";
>>>>>>
>>>>>> private final static int MAX_LINE_LENGTH_DEFAULT = 80;
>>>>>>
>>>>>> private final static String HEADER_FILE_KEY = "maven.sourcedef.header.file";
>>>>>>
>>>>>> private final static String HEADER_FILE_DEFAULT = "LICENSE.txt";
>>>>>>
>>>>>> private final static String ALLOW_TABS_KEY = "maven.sourcedef.allow.tabs";
>>>>>>
>>>>>> private final static boolean ALLOW_TABS_DEFAULT = false;
>>>>>>
>>>>>> private final static String FOLLOW_JLS_ORDER_KEY =
>"maven.sourcedef.follow.jls.order";
>>>>>>
>>>>>> private final static boolean FOLLOW_JLS_ORDER_DEFAULT = true;
>>>>>>
>>>>>> private static Hashtable projectProps = null;
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * provides SourceDefinition with access to the ant properties
>>>>>> *
>>>>>> * @param props the hashtable of the ant properties.
>>>>>> */
>>>>>> public final static void setProjectProperties(Hashtable props) {
>>>>>> projectProps = props;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * @return the block brace style
>>>>>> */
>>>>>> public final static String getBlockBraceStyle() {
>>>>>>
>>>>>> return getStringProperty(BLOCK_BRACE_STYLE_KEY,
>>>>>> BLOCK_BRACE_STYLE_DEFAULT,
>>>>>> BRACE_STYLE_ALLOWED);
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * Gets the methodBraceStyle attribute of the SourceDefinition class
>>>>>> *
>>>>>> * @return The methodBraceStyle value
>>>>>> */
>>>>>> public final static String getMethodBraceStyle() {
>>>>>>
>>>>>> return getStringProperty(METHOD_BRACE_STYLE_KEY,
>>>>>> METHOD_BRACE_STYLE_DEFAULT,
>>>>>> BRACE_STYLE_ALLOWED);
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * Gets the classBraceStyle attribute of the SourceDefinition class
>>>>>> *
>>>>>> * @return The classBraceStyle value
>>>>>> */
>>>>>> public final static String getClassBraceStyle() {
>>>>>>
>>>>>> return getStringProperty(CLASS_BRACE_STYLE_KEY,
>>>>>> CLASS_BRACE_STYLE_DEFAULT,
>>>>>> BRACE_STYLE_ALLOWED);
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * Gets the keywordLocationRightBrace attribute of the SourceDefinition
>>>>>> * class
>>>>>> *
>>>>>> * @return The keywordLocationRightBrace value
>>>>>> */
>>>>>> public final static String getKeywordLocationRightBrace() {
>>>>>> return getStringProperty(KEYWORD_LOCATION_RIGHT_BRACE_KEY,
>>>>>> KEYWORD_LOCATION_RIGHT_BRACE_DEFAULT,
>>>>>> KEYWORD_LOCATION_RIGHT_BRACE_ALLOWED);
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * Gets the allowTabs attribute of the SourceDefinition class
>>>>>> *
>>>>>> * @return The allowTabs value
>>>>>> */
>>>>>> public final static boolean getAllowTabs() {
>>>>>> return getBooleanProperty(ALLOW_TABS_KEY, ALLOW_TABS_DEFAULT);
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * Gets the maxLineLength attribute of the SourceDefinition class
>>>>>> *
>>>>>> * @return The maxLineLength value
>>>>>> */
>>>>>> public final static int getMaxLineLength() {
>>>>>>
>>>>>> return getIntProperty(MAX_LINE_LENGTH_KEY, MAX_LINE_LENGTH_DEFAULT);
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * Gets the headerFile attribute of the SourceDefinition class
>>>>>> *
>>>>>> * @return The headerFile value
>>>>>> */
>>>>>> public final static File getHeaderFile() {
>>>>>> return getFileProperty(HEADER_FILE_KEY, HEADER_FILE_DEFAULT);
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * Gets the followJlsOrder attribute of the SourceDefinition class
>>>>>> *
>>>>>> * @return The followJlsOrder value
>>>>>> */
>>>>>> public final static boolean getFollowJlsOrder() {
>>>>>> return getBooleanProperty(FOLLOW_JLS_ORDER_KEY,
>>>>>> FOLLOW_JLS_ORDER_DEFAULT);
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * Gets the intProperty attribute of the SourceDefinition class
>>>>>> *
>>>>>> * @param key Description of the Parameter
>>>>>> * @param defaultValue Description of the Parameter
>>>>>> * @return The intProperty value
>>>>>> */
>>>>>> public final static int getIntProperty(String key, int defaultValue) {
>>>>>>
>>>>>> String propStr = (String) projectProps.get(key);
>>>>>> int prop = 0;
>>>>>> if (propStr != null) {
>>>>>> prop = Integer.parseInt(propStr);
>>>>>> } else {
>>>>>> prop = defaultValue;
>>>>>> }
>>>>>> return prop;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * Gets the booleanProperty attribute of the SourceDefinition class
>>>>>> *
>>>>>> * @param key Description of the Parameter
>>>>>> * @param defaultValue Description of the Parameter
>>>>>> * @return The booleanProperty value
>>>>>> */
>>>>>> private final static boolean getBooleanProperty(String key, boolean
>defaultValue) {
>>>>>> String propStr = (String) projectProps.get(key);
>>>>>> boolean prop = false;
>>>>>> if (propStr != null) {
>>>>>> prop = new Boolean(propStr).booleanValue();
>>>>>> } else {
>>>>>> prop = defaultValue;
>>>>>> }
>>>>>> return prop;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * Gets the stringProperty attribute of the SourceDefinition class
>>>>>> *
>>>>>> * @param key Description of the Parameter
>>>>>> * @param defaultValue Description of the Parameter
>>>>>> * @param allowedValues Description of the Parameter
>>>>>> * @return The stringProperty value
>>>>>> */
>>>>>> private final static String getStringProperty(String key, String
>defaultValue, String[] allowedValues) {
>>>>>>
>>>>>> String prop = (String) projectProps.get(key);
>>>>>> //String prop = (String) projectProps.get(key,defaultValue);
>>>>>> System.out.println("key = " + key + " val = " + prop + " default " +
>>>>>> defaultValue + " allowed = " + allowedValues);
>>>>>> if (prop == null) {
>>>>>> prop = defaultValue;
>>>>>> }
>>>>>> if (allowedValues != null) {
>>>>>> List list = Arrays.asList(allowedValues);
>>>>>> if (!list.contains(prop)) {
>>>>>> StringBuffer sb = new StringBuffer("unrecognised value: ");
>>>>>> sb.append(prop);
>>>>>> sb.append(" for property: ");
>>>>>> sb.append(key);
>>>>>> sb.append(" allowed values are: ");
>>>>>> for (int i = 0; i < allowedValues.length; i++) {
>>>>>> sb.append(allowedValues[i]);
>>>>>> if (i < (allowedValues.length - 1)) {
>>>>>> sb.append(",");
>>>>>> }
>>>>>> }
>>>>>> throw new BuildException(sb.toString());
>>>>>> }
>>>>>> }
>>>>>> return prop;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>> * Gets the fileProperty attribute of the SourceDefinition class
>>>>>> *
>>>>>> * @param key Description of the Parameter
>>>>>> * @param defaultValue Description of the Parameter
>>>>>> * @return The fileProperty value
>>>>>> */
>>>>>> private final static File getFileProperty(String key, String defaultValue) {
>>>>>> String prop = (String) projectProps.get(key);
>>>>>> if (prop == null) {
>>>>>> prop = defaultValue;
>>>>>> }
>>>>>> return new File(prop);
>>>>>> }
>>>>>>}
>>>>>>
>>>>>>
>>>>>>
>>>>>>------------------------------------------------------------------------
>>>>>>
>>>>>>--
>>>>>>To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
>>>>>>For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>
>>>>>>
Index: jakarta-turbine-maven/build.xml
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-maven/build.xml,v
retrieving revision 1.37
diff -u -r1.37 build.xml
--- jakarta-turbine-maven/build.xml 19 May 2002 01:41:14 -0000 1.37
+++ jakarta-turbine-maven/build.xml 29 May 2002 09:19:06 -0000
@@ -147,6 +147,10 @@
<target name="maven:check-source">
<ant antfile="${maven.home}/plugins/core/build.xml" target="check-source"/>
</target>
+
+ <target name="maven:pretty-print">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="pretty-print"/>
+ </target>
<target name="maven:dist">
<ant antfile="${maven.home}/plugins/core/build.xml" target="dist"/>
Index: jakarta-turbine-maven/src/templates/build/plugins/core/build.xml
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/core/build.xml,v
retrieving revision 1.4
diff -u -r1.4 build.xml
--- jakarta-turbine-maven/src/templates/build/plugins/core/build.xml 27 May 2002
07:50:45 -0000 1.4
+++ jakarta-turbine-maven/src/templates/build/plugins/core/build.xml 29 May 2002
+09:19:29 -0000
@@ -329,6 +329,49 @@
</target>
+
+ <!-- ================================================================== -->
+ <!-- JRefactory Pretty Print -->
+ <!-- ================================================================== -->
+
+ <target
+ name="pretty-print"
+ depends="local-init, env"
+ description="modify code according to maven source definition">
+
+ <taskdef
+ name="prettyprintconfig"
+ classname="org.apache.maven.sourcedef.PrettyPrintConfigTask">
+ <classpath refid="maven-classpath"/>
+ </taskdef>
+
+ <prettyprintconfig/>
+
+ <taskdef name="filesetfrompath"
+ classname="org.apache.maven.ant.FileSetFromPath">
+ <classpath>
+ <path refid="maven-classpath"/>
+ </classpath>
+ </taskdef>
+
+ <filesetfrompath pathid="maven.src.set"
+ filesetid="maven.sourceDirectories.fileset"
+ includes="${maven.jrefactory.includes}"
+ excludes="${maven.jrefactory.excludes}"/>
+
+ <taskdef
+ name="prettyprint"
+ classname="org.acm.seguin.ant.Pretty">
+ <classpath refid="maven-classpath"/>
+ </taskdef>
+
+ <prettyprint settingsDir="${maven.build.dir}">
+ <fileset refid="maven.sourceDirectories.fileset" />
+ </prettyprint>
+
+ </target>
+
+
<!-- ================================================================== -->
<!-- C H E C K S O U R C E -->
<!-- ================================================================== -->
@@ -339,6 +382,13 @@
<target name="do-check-source" if="maven.sourcesPresent">
+ <taskdef
+ name="checkstyleconfig"
+ classname="org.apache.maven.sourcedef.CheckStyleConfigTask">
+ <classpath refid="maven-classpath"/>
+ </taskdef>
+
+
<taskdef
name="checkstyle"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
@@ -363,55 +413,22 @@
includes="${maven.checkstyle.includes}"
excludes="${maven.checkstyle.excludes}"/>
- <checkstyle
- lcurlyType="${maven.checkstyle.lcurly.type}"
- lcurlyMethod="${maven.checkstyle.lcurly.method}"
- lcurlyOther="${maven.checkstyle.lcurly.other}"
- rcurly="${maven.checkstyle.rcurly}"
- parenPad="${maven.checkstyle.paren.pad}"
- allowTabs="${maven.checkstyle.allow.tabs}"
- allowProtected="${maven.checkstyle.allow.protected}"
- allowPackage="${maven.checkstyle.allow.package}"
- allowNoAuthor="${maven.checkstyle.allow.no.author}"
- maxLineLen="${maven.checkstyle.max.line.len}"
- tabWidth="${maven.checkstyle.tab.width}"
- ignoreLineLengthPattern="${maven.checkstyle.ignore.line.len.pattern}"
- maxMethodLen="${maven.checkstyle.max.method.len}"
- maxConstructorLen="${maven.checkstyle.max.constructor.len}"
- maxFileLen="${maven.checkstyle.max.file.len}"
- ignoreImportLen="${maven.checkstyle.ignore.import.len}"
- memberPattern="${maven.checkstyle.member.pattern}"
- publicMemberPattern="${maven.checkstyle.public.member.pattern}"
- paramPattern="${maven.checkstyle.param.pattern}"
- constPattern="${maven.checkstyle.const.pattern}"
- staticPattern="${maven.checkstyle.static.pattern}"
- typePattern="${maven.checkstyle.type.pattern}"
- methodPattern="${maven.checkstyle.method.pattern}"
- localVarPattern="${maven.checkstyle.local.var.pattern}"
- headerFile="${maven.checkstyle.header.file}"
- headerLinesRegexp="${maven.checkstyle.header.lines.regexp}"
- headerIgnoreLine="${maven.checkstyle.header.ignore.line}"
- javadocScope="${maven.checkstyle.javadoc.scope}"
- requirePackageHtml="${maven.checkstyle.require.package.html}"
- ignoreImports="${maven.checkstyle.ignore.imports}"
- illegalImports="${maven.checkstyle.illegal.imports}"
- ignoreWhitespace="${maven.checkstyle.ignore.whitespace}"
- ignoreCastWhitespace="${maven.checkstyle.ignore.cast.whitespace}"
- ignoreBraces="${maven.checkstyle.ignore.braces}"
- ignorePublicInInterface="${maven.checkstyle.ignore.public.in.interface}"
- failOnViolation="${maven.checkstyle.fail.on.violation}"
- cacheFile="${maven.checkstyle.cache.file}" >
+ <checkstyleconfig/>
+
+ <checkstyle
+ properties="${maven.checkstyle.dir}/CheckStyleConfig.properties"
+ failOnViolation="${maven.checkstyle.fail.on.violation}">
<fileset refid="maven.sourceDirectories.fileset" />
- <formatter type="xml" toFile="${maven.build.dir}/checkstyle-raw-report.xml"/>
- <formatter type="plain" toFile="${maven.build.dir}/checkstyle-raw-report.txt"/>
+ <formatter type="xml"
+toFile="${maven.checkstyle.dir}/checkstyle-raw-report.xml"/>
+ <formatter type="plain"
+toFile="${maven.checkstyle.dir}/checkstyle-raw-report.txt"/>
</checkstyle>
<dvsl
basedir="."
style="${maven.home}/stylesheets/checkstyle.dvsl"
toolboxfile="${maven.home}/stylesheets/toolbox.props"
- in="${maven.build.dir}/checkstyle-raw-report.xml"
- out="${maven.gen.docs}/checkstyle-report.xml">
+ in="${maven.checkstyle.dir}/checkstyle-raw-report.xml"
+ out="${maven.checkstyle.dir}/checkstyle-report.xml">
<!-- Need to add the maven jar to load the toolbox -->
<classpath>
<path refid="maven-classpath"/>
Index: jakarta-turbine-maven/src/templates/build/plugins/core/default.properties
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-maven/src/templates/build/plugins/core/default.properties,v
retrieving revision 1.4
diff -u -r1.4 default.properties
--- jakarta-turbine-maven/src/templates/build/plugins/core/default.properties 27 May
2002 08:02:41 -0000 1.4
+++ jakarta-turbine-maven/src/templates/build/plugins/core/default.properties 29 May
+2002 09:19:54 -0000
@@ -75,21 +75,29 @@
maven.jxr.destdir = ${maven.docs.dest}/xref
#
+# source definition properties. if not set, default values below are
+# set by org.apache.maven.sourcedef.SourceDefinition
+#
+
+#maven.sourcedef.class.brace.style=PASCAL
+#maven.sourcedef.method.brace.style=PASCAL
+#maven.sourcedef.block.brace.style=PASCAL
+#maven.sourcedef.keyword.location.right.brace=alone
+#maven.sourcedef.max.line.len=80
+#maven.sourcedef.header.file=LICENSE.txt
+#maven.sourcedef.allow.tabs=false
+
+#
# Checkstyle settings ... default maven settings, these can be
# overridden in a project specific properties file.
#
+maven.checkstyle.dir=${maven.build.dir}/checkstyle
maven.checkstyle.includes = **/*.java
maven.checkstyle.excludes =
-maven.checkstyle.lcurly.type = nl
-maven.checkstyle.lcurly.method = nl
-maven.checkstyle.lcurly.other = nl
-maven.checkstyle.rcurly = alone
maven.checkstyle.paren.pad = nospace
-maven.checkstyle.allow.tabs = false
maven.checkstyle.allow.protected = false
maven.checkstyle.allow.package = false
maven.checkstyle.allow.no.author = false
-maven.checkstyle.max.line.len = 80
maven.checkstyle.tab.width = 8
maven.checkstyle.ignore.line.len.pattern = ^$
maven.checkstyle.max.method.len = 150
@@ -104,9 +112,8 @@
maven.checkstyle.type.pattern = ^[A-Z][a-zA-Z0-9]*$
maven.checkstyle.method.pattern = ^[a-z][a-zA-Z0-9]*$
maven.checkstyle.local.var.pattern = ^[a-z][a-zA-Z0-9]*$
-maven.checkstyle.header.file = LICENSE.txt
maven.checkstyle.header.lines.regexp = false
-maven.checkstyle.header.ignore.line = 1,6
+maven.checkstyle.header.ignore.line=
maven.checkstyle.javadoc.scope = private
maven.checkstyle.require.package.html = false
maven.checkstyle.ignore.imports = false
@@ -116,7 +123,94 @@
maven.checkstyle.ignore.braces = false
maven.checkstyle.ignore.public.in.interface = false
maven.checkstyle.fail.on.violation = false
-maven.checkstyle.cache.file = ${maven.build.dir}/checkstyle-cachefile
+maven.checkstyle.cache.file = ${maven.checkstyle.dir}/checkstyle-cachefile
+
+#
+# jrefactroy properties
+#
+
+maven.jrefactory.includes=**/*.java
+maven.jrefactory.excludes=
+maven.jrefactory.version=3.8
+maven.jrefactory.indent=4
+maven.jrefactory.indent.char=space
+maven.jrefactory.expr.space=false
+maven.jrefactory.lines.between=2
+maven.jrefactory.cast.space=true
+maven.jrefactory.cast.force.nospace=false
+maven.jrefactory.surprise.return=double
+maven.jrefactory.throws.newline=false
+maven.jrefactory.field.name.indent=-1
+maven.jrefactory.end.line=CRNL
+maven.jrefactory.variable.spacing=single
+maven.jrefactory.dynamic.variable.spacing=1
+maven.jrefactory.variable.align.with.block=false
+maven.jrefactory.case.indent=4
+maven.jrefactory.keyword.space=true
+maven.jrefactory.insert.space.around.local.variables=false
+maven.jrefactory.lines.after.package=1
+maven.jrefactory.maintain.newlines.around.imports=true
+maven.jrefactory.lines.before.class=0
+maven.jrefactory.indent.in.initializer=false
+maven.jrefactory.bang.space=false
+maven.jrefactory.method.space=false
+maven.jrefactory.cast.inside.space=false
+maven.jrefactory.space.around.ops=true
+maven.jrefactory.force.block=true
+maven.jrefactory.empty.block.single.line=true
+maven.jrefactory.remove.excess.blocks=false
+maven.jrefactory.singleline.comment.ownline=true
+maven.jrefactory.singleline.comment.absoluteindent=0
+maven.jrefactory.singleline.comment.incrementalindent=0
+maven.jrefactory.singleline.comment.indentstyle.shared=incremental
+maven.jrefactory.singleline.comment.indentstyle.ownline=code
+maven.jrefactory.c.style.format=align.star
+maven.jrefactory.c.style.indent=2
+maven.jrefactory.method.minimum=all
+maven.jrefactory.field.minimum=protected
+maven.jrefactory.class.minimum=all
+maven.jrefactory.javadoc.star=2
+maven.jrefactory.javadoc.wordwrap.min=40
+maven.jrefactory.space.before.javadoc=true
+maven.jrefactory.javadoc.id.lineup=true
+maven.jrefactory.javadoc.indent=2
+maven.jrefactory.reformat.comments=true
+maven.jrefactory.exception.tag.name=@exception
+maven.jrefactory.document.nested.classes=true
+maven.jrefactory.allow.singleline.javadoc=false
+maven.jrefactory.keep.all.javadoc=false
+maven.jrefactory.class.descr=Description of the Class
+maven.jrefactory.interface.descr=Description of the Interface
+maven.jrefactory.constructor.descr=Constructor for the {0} object
+maven.jrefactory.method.descr=Description of the Method
+maven.jrefactory.getter.descr=Gets the {3} attribute of the {1} {2}
+maven.jrefactory.getter.return.descr=The {3} value
+maven.jrefactory.setter.descr=Sets the {3} attribute of the {1} {2}
+maven.jrefactory.setter.param.descr=The new {3} value
+maven.jrefactory.field.descr=Description of the Field
+maven.jrefactory.run.descr=Main processing method for the {1} {2}
+maven.jrefactory.main.descr=The main program for the {1} {2}
+maven.jrefactory.main.param.descr=The command line arguments
+maven.jrefactory.adder.descr=Adds a feature to the {0} attribute of the {1} {2}
+maven.jrefactory.adder.param.descr=The feature to be added to the {0} attribute
+maven.jrefactory.junit.setUp.descr=The JUnit setup method
+maven.jrefactory.junit.test.descr=A unit test for JUnit
+maven.jrefactory.junit.tearDown.descr=The teardown method for JUnit
+maven.jrefactory.junit.suite.descr=A unit test suite for JUnit
+maven.jrefactory.junit.suite.return.descr=The test suite
+maven.jrefactory.author.descr={0}
+maven.jrefactory.created.descr={1}
+maven.jrefactory.param.descr=Description of the Parameter
+maven.jrefactory.return.descr=Description of the Return Value
+maven.jrefactory.exception.descr=Description of the Exception
+maven.jrefactory.class.tags=created
+maven.jrefactory.method.tags=param,return,exception
+maven.jrefactory.field.tags=
+maven.jrefactory.char.stream.type=1
+maven.jrefactory.pretty.printer.backup.ext=
+maven.jrefactory.sort.top=false
+maven.jrefactory.import.sort.important=
+maven.jrefactory.import.sort.neighbourhood=0
#
# UI Color Prefs
Index: jakarta-turbine-maven/jars.list
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-maven/jars.list,v
retrieving revision 1.9
diff -u -r1.9 jars.list
--- jakarta-turbine-maven/jars.list 12 May 2002 15:18:08 -0000 1.9
+++ jakarta-turbine-maven/jars.list 29 May 2002 09:20:18 -0000
@@ -39,3 +39,4 @@
regexp-1.2.jar
velocity-1.3-dev.jar
velocity-dvsl-0.43.jar
+jrefactory.jar
Index: jakarta-turbine-maven/project.xml
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-maven/project.xml,v
retrieving revision 1.80
diff -u -r1.80 project.xml
--- jakarta-turbine-maven/project.xml 26 May 2002 16:17:36 -0000 1.80
+++ jakarta-turbine-maven/project.xml 29 May 2002 09:20:34 -0000
@@ -327,6 +327,15 @@
<url>http://www.clarkware.com/software/JDepend.html</url>
</dependency>
+ <dependency>
+ <name>jrefactory</name>
+ <type>required</type>
+ <version>2.6.36</version>
+ <jar>jrefactory.jar</jar>
+ <url>http://jrefactory.sourceforge.net/chrissoft.html</url>
+ </dependency>
+
+
<!-- maven:pdf requirements
<dependency>
<name>fop</name>
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.maven.sourcedef;
import java.io.File;
import com.puppycrawl.tools.checkstyle.CheckStyleTask;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.Project;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Iterator;
/**
* task responsible for writing the checkstyle config file by combining
* properties with these prefixes maven.sourcedef and maven.checkstyle. generic
* maven.sourcedef properties are converted to checkstyle counterpart. For
* allowed properties and conversions see the {@link org.apache.maven.sourcedef
* package description}.
*
* @created 28 May 2002
* @author Nathan Coast ([EMAIL PROTECTED])
*/
public class CheckStyleConfigTask extends Task {
/**
* checkstyle property name for the class brace style property
*/
private final static String CLASS_BRACE_STYLE_KEY = "checkstyle.lcurly.type";
/**
* checkstyle property name for the method brace style property
*/
private final static String METHOD_BRACE_STYLE_KEY = "checkstyle.lcurly.method";
/**
* checkstyle property name for the all other brace styles
*/
private final static String OTHER_BRACE_STYLE_KEY = "checkstyle.lcurly.other";
/**
* checkstyle property name for the location of keyword relative to right
* brace.
*/
private final static String RIGHT_BRACE_KEYWORD_LOCATION_KEY =
"checkstyle.rcurly";
/**
* checkstyle property name for allow tabs property
*/
private final static String ALLOW_TABS_KEY = "checkstyle.allow.tabs";
/**
* checkstyle property name for max line lenght property
*/
private final static String MAX_LINE_LENGTH_KEY = "checkstyle.maxlinelen";
/**
* checkstyle property name for header file property
*/
private final static String HEADER_FILE_KEY = "checkstyle.header.file";
/**
* eol left brace style value
*/
private final static String LEFT_CURLY_EOL = "eol";
/**
* nl left brace style value
*/
private final static String LEFT_CURLY_NL = "nl";
/**
* name of the generated checkstyle config file
*/
private final static String CONFIG_FILENAME = "CheckStyleConfig.properties";
/**
* prefix for checkstyle properties in default.properties
*/
private final static String CHECKSTYLE_PROP_PREFIX = "maven.checkstyle.";
/**
* execute method to combine the maven.checkstyle properties with converted
* maven.sourcedef properties and write them to
* ${maven.checkstyle.dir}/CheckStyleConfig.properties
*
* @exception BuildException Description of the Exception
*/
public void execute() throws BuildException {
Project project = getProject();
Hashtable props = project.getProperties();
String checkstyleDirStr = (String) props.get("maven.checkstyle.dir");
File checkstyleDir = new File(checkstyleDirStr);
if (!checkstyleDir.exists()) {
if (!checkstyleDir.mkdir()) {
throw new BuildException("unable to create checkstyle directory: "
+ checkstyleDir);
}
}
File configFile = new File(checkstyleDir, CONFIG_FILENAME);
Properties config = new Properties();
Iterator it = props.keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
if (key.startsWith(CHECKSTYLE_PROP_PREFIX)) {
config.put(key.substring(6), props.get(key));
}
}
SourceDefinition.setProjectProperties(getProject().getProperties());
String classBraceStyle = SourceDefinition.getClassBraceStyle();
classBraceStyle = convertLeftBraceType(classBraceStyle);
config.put(CLASS_BRACE_STYLE_KEY, classBraceStyle);
String methodBraceStyle = SourceDefinition.getMethodBraceStyle();
methodBraceStyle = convertLeftBraceType(methodBraceStyle);
config.put(METHOD_BRACE_STYLE_KEY, methodBraceStyle);
String blockBraceStyle = SourceDefinition.getBlockBraceStyle();
blockBraceStyle = convertLeftBraceType(blockBraceStyle);
config.put(OTHER_BRACE_STYLE_KEY, blockBraceStyle);
config.put(RIGHT_BRACE_KEYWORD_LOCATION_KEY,
SourceDefinition.getKeywordLocationRightBrace());
config.put(ALLOW_TABS_KEY, "" + SourceDefinition.getAllowTabs());
config.put(MAX_LINE_LENGTH_KEY, "" + SourceDefinition.getMaxLineLength());
File headerFile = SourceDefinition.getHeaderFile();
if (headerFile.exists() && headerFile.canRead() && headerFile.isFile()) {
config.put(HEADER_FILE_KEY, headerFile.toString());
}
FileOutputStream fos = null;
try {
fos = new FileOutputStream(configFile);
config.store(fos, "this is a generated file do not edit");
} catch (IOException e) {
throw new BuildException(e);
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* utility to convert between maven.sourcedef properties and checkstyle.
* properties for the left brace style.
*
* @param type the maven.sourcedef property to convert
* @return the maven.sourcedef property converted to checkstyle
* property.
*/
private static String convertLeftBraceType(String type) {
String convertedType = null;
if (SourceDefinition.BRACE_STYLE_C.equals(type)) {
convertedType = LEFT_CURLY_EOL;
} else if (SourceDefinition.BRACE_STYLE_PASCAL.equals(type)) {
convertedType = LEFT_CURLY_NL;
} else {
throw new BuildException("Unknown left brace type " + type);
}
return convertedType;
}
}
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.maven.sourcedef;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import java.util.Properties;
import java.util.Iterator;
import java.util.Set;
import java.util.Hashtable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
/**
* task responsible for writing the Jrefactory pretty print config file by
* combining properties with these prefixes maven.sourcedef and
* maven.jrefactory. Generic maven.sourcedef properties are converted to their
* jrefactory counterparts. For allowed properties and conversions see the
* {@link org.apache.maven.sourcedef package description}.
*
* @created 28 May 2002
* @author Nathan Coast ([EMAIL PROTECTED])
*/
public class PrettyPrintConfigTask extends Task {
/**
* jrefactory property name for the catch start line property
*/
private final static String CATCH_START_LINE = "catch.start.line";
/**
* jrefactory property name for the else start line property
*/
private final static String ELSE_START_LINE = "else.start.line";
/**
* jrefactory property name for the block property
*/
private final static String BLOCK_STYLE = "block.style";
/**
* jrefactory property name for the method block style property
*/
private final static String METHOD_BLOCK_STYLE = "method.block.style";
/**
* jrefactory property name for the class block style property
*/
private final static String CLASS_BLOCK_STYLE = "class.block.style";
/**
* jrefactory property name for the javadoc wordwrap property
*/
private final static String JAVADOC_WORDWRAP_MAX = "javadoc.wordwrap.max";
/**
* allowed 'space' value for the indent char property
*/
private final static String SPACE = "space";
/**
* allowed 'tab' value for the indent char property
*/
private final static String TAB = "tab";
/**
* jrefactory property name for the indent char property
*/
private final static String INDENT_CHAR = "indent.char";
/**
* prefix for jrefactory specific propeties
*/
private final static String JREFACTORY_PROP_PREFIX = "maven.jrefactory.";
/**
* execute method to combine the maven.jrefactory properties with converted
* maven.sourcedef properties and write them to the file
* ${maven.build.dir}/.Refactory/pretty.settings
*
* @exception BuildException Description of the Exception
*/
public void execute() throws BuildException {
Hashtable props = getProject().getProperties();
SourceDefinition.setProjectProperties(props);
Properties config = new Properties();
Iterator it = props.keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
if (key.startsWith(JREFACTORY_PROP_PREFIX)) {
config.put(key.substring(JREFACTORY_PROP_PREFIX.length()),
props.get(key));
}
}
String buildDirStr = (String) props.get("maven.build.dir");
File buildDir = new File(buildDirStr);
File prettyDir = new File(buildDir, ".Refactory");
if (!prettyDir.exists()) {
if (!prettyDir.mkdir()) {
throw new BuildException(
"unable to create jrefactory pretty print config directory: "
+ prettyDir);
}
}
File prettySettings = new File(prettyDir, "pretty.settings");
if (prettySettings.exists()) {
prettySettings.delete();
}
FileOutputStream fos = null;
try {
String classBlockStyle = SourceDefinition.getClassBraceStyle();
config.put(CLASS_BLOCK_STYLE, classBlockStyle);
String methodBlockStyle = SourceDefinition.getMethodBraceStyle();
config.put(METHOD_BLOCK_STYLE, methodBlockStyle);
String blockStyle = SourceDefinition.getBlockBraceStyle();
config.put(BLOCK_STYLE, blockStyle);
String keyLoc = SourceDefinition.getKeywordLocationRightBrace();
String catchStartLine = convertKeywordLocationRightBrace(keyLoc);
config.put(CATCH_START_LINE, catchStartLine);
config.put(ELSE_START_LINE, catchStartLine);
File headerFile = SourceDefinition.getHeaderFile();
populateHeaderFile(headerFile, config);
int javadocWordwrapMax = SourceDefinition.getMaxLineLength();
config.put(JAVADOC_WORDWRAP_MAX, "" + javadocWordwrapMax);
boolean allowTabs = SourceDefinition.getAllowTabs();
String indentChar = convertAllowTabs(allowTabs);
config.put(INDENT_CHAR, indentChar);
/*
* if(SourceDefinition.getFollowJlsOrder()){
*
config.put("sort.1","Type(Field,Constructor,Method,NestedClass,NestedInterface,Initializer)");
* config.put("sort.2","Class(Instance,Static)");
* config.put("sort.3","Method(setter,getter,other)");
* config.put("sort.4","Final(top)");
* config.put("sort.5","Protection(public)");
* config.put("sort.6","Bean()");
* config.put("sort.7","Alphabetical()");
* config.put("sort.8","FieldInitializers()");
* }
*/
//File tmpPrettyProps = new File("tmpPrettyProps.settings");
fos = new FileOutputStream(prettySettings);
config.store(fos, "this is a generated file do not edit");
} catch (IOException e) {
throw new BuildException(e);
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* method to convert property from maven.sourcedef.keyword.location.right.brace
* to jrefactory property values.
*
* @param location the maven.sourcdef property
* @return the property converted to a jrefactory property
*/
private static String convertKeywordLocationRightBrace(String location) {
String convertedLocation = null;
if (SourceDefinition.KEYWORD_LOCATION_RIGHT_BRACE_SAME.equals(location)) {
convertedLocation = "false";
} else if
(SourceDefinition.KEYWORD_LOCATION_RIGHT_BRACE_ALONE.equals(location)) {
convertedLocation = "true";
} else {
throw new BuildException("Unrecognised keyword location " + location);
}
return convertedLocation;
}
/**
* method to read the header file and populate the contents of the file
* into the properties using the property names 'header.[line_num]'
*
* @param headerFile the headerFile
* @param props the properties to load the header file into.
* @exception IOException Description of the Exception
*/
private static void populateHeaderFile(File headerFile, Properties props)
throws IOException {
FileReader fr = new FileReader(headerFile);
BufferedReader br = new BufferedReader(fr);
String str = null;
int count = 0;
while ((str = br.readLine()) != null) {
count++;
String headerLine = "header." + count;
props.put(headerLine, str);
}
}
/**
* method to convert the maven.sourcedef.allow.tabs property to the
* appropriate jrefactory property
*
* @param allowTabs the maven.sourcedef.allow.tabs property
* @return allow tabs property converted to jrefactory property
*/
private static String convertAllowTabs(boolean allowTabs) {
String indentChar = null;
if (allowTabs) {
indentChar = TAB;
} else {
indentChar = SPACE;
}
return indentChar;
}
}
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.maven.sourcedef;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.Hashtable;
import org.apache.tools.ant.BuildException;
/**
* Utility class to provide access to the maven.sourcedef properties. If a
* property exisits in the project properties, it is against allowed values for
* that property (if there are any). If the property isn't set, a default is
* returned.
*
* @created 28 May 2002
* @author Nathan Coast ([EMAIL PROTECTED])
*/
class SourceDefinition {
/**
* value for 'C' brace style
*/
public final static String BRACE_STYLE_C = "C";
/**
* value for 'pascal' brace style
*/
public final static String BRACE_STYLE_PASCAL = "PASCAL";
/**
* allowed brace styles 'C' or 'PASCAL'
*/
private final static String[] BRACE_STYLE_ALLOWED = {BRACE_STYLE_C,
BRACE_STYLE_PASCAL};
/**
* property name for block brace style
*/
private final static String BLOCK_BRACE_STYLE_KEY =
"maven.sourcedef.block.brace.style";
/**
* default value for block brace style
*/
private final static String BLOCK_BRACE_STYLE_DEFAULT = BRACE_STYLE_C;
private final static String METHOD_BRACE_STYLE_KEY =
"maven.sourcedef.method.brace.style";
private final static String METHOD_BRACE_STYLE_DEFAULT = BRACE_STYLE_C;
private final static String CLASS_BRACE_STYLE_KEY =
"maven.sourcedef.class.brace.style";
private final static String CLASS_BRACE_STYLE_DEFAULT = BRACE_STYLE_C;
/**
* Description of the Field
*/
public final static String KEYWORD_LOCATION_RIGHT_BRACE_SAME = "same";
/**
* Description of the Field
*/
public final static String KEYWORD_LOCATION_RIGHT_BRACE_ALONE = "alone";
private final static String[] KEYWORD_LOCATION_RIGHT_BRACE_ALLOWED =
{KEYWORD_LOCATION_RIGHT_BRACE_SAME,
KEYWORD_LOCATION_RIGHT_BRACE_ALONE};
private final static String KEYWORD_LOCATION_RIGHT_BRACE_KEY =
"maven.sourcedef.keyword.location.right.brace";
private final static String KEYWORD_LOCATION_RIGHT_BRACE_DEFAULT =
KEYWORD_LOCATION_RIGHT_BRACE_SAME;
private final static String MAX_LINE_LENGTH_KEY = "maven.sourcedef.max.line.len";
private final static int MAX_LINE_LENGTH_DEFAULT = 80;
private final static String HEADER_FILE_KEY = "maven.sourcedef.header.file";
private final static String HEADER_FILE_DEFAULT = "LICENSE.txt";
private final static String ALLOW_TABS_KEY = "maven.sourcedef.allow.tabs";
private final static boolean ALLOW_TABS_DEFAULT = false;
private final static String FOLLOW_JLS_ORDER_KEY =
"maven.sourcedef.follow.jls.order";
private final static boolean FOLLOW_JLS_ORDER_DEFAULT = true;
private static Hashtable projectProps = null;
/**
* provides SourceDefinition with access to the ant properties
*
* @param props the hashtable of the ant properties.
*/
public final static void setProjectProperties(Hashtable props) {
projectProps = props;
}
/**
* @return the block brace style
*/
public final static String getBlockBraceStyle() {
return getStringProperty(BLOCK_BRACE_STYLE_KEY,
BLOCK_BRACE_STYLE_DEFAULT,
BRACE_STYLE_ALLOWED);
}
/**
* Gets the methodBraceStyle attribute of the SourceDefinition class
*
* @return The methodBraceStyle value
*/
public final static String getMethodBraceStyle() {
return getStringProperty(METHOD_BRACE_STYLE_KEY,
METHOD_BRACE_STYLE_DEFAULT,
BRACE_STYLE_ALLOWED);
}
/**
* Gets the classBraceStyle attribute of the SourceDefinition class
*
* @return The classBraceStyle value
*/
public final static String getClassBraceStyle() {
return getStringProperty(CLASS_BRACE_STYLE_KEY,
CLASS_BRACE_STYLE_DEFAULT,
BRACE_STYLE_ALLOWED);
}
/**
* Gets the keywordLocationRightBrace attribute of the SourceDefinition
* class
*
* @return The keywordLocationRightBrace value
*/
public final static String getKeywordLocationRightBrace() {
return getStringProperty(KEYWORD_LOCATION_RIGHT_BRACE_KEY,
KEYWORD_LOCATION_RIGHT_BRACE_DEFAULT,
KEYWORD_LOCATION_RIGHT_BRACE_ALLOWED);
}
/**
* Gets the allowTabs attribute of the SourceDefinition class
*
* @return The allowTabs value
*/
public final static boolean getAllowTabs() {
return getBooleanProperty(ALLOW_TABS_KEY, ALLOW_TABS_DEFAULT);
}
/**
* Gets the maxLineLength attribute of the SourceDefinition class
*
* @return The maxLineLength value
*/
public final static int getMaxLineLength() {
return getIntProperty(MAX_LINE_LENGTH_KEY, MAX_LINE_LENGTH_DEFAULT);
}
/**
* Gets the headerFile attribute of the SourceDefinition class
*
* @return The headerFile value
*/
public final static File getHeaderFile() {
return getFileProperty(HEADER_FILE_KEY, HEADER_FILE_DEFAULT);
}
/**
* Gets the followJlsOrder attribute of the SourceDefinition class
*
* @return The followJlsOrder value
*/
public final static boolean getFollowJlsOrder() {
return getBooleanProperty(FOLLOW_JLS_ORDER_KEY,
FOLLOW_JLS_ORDER_DEFAULT);
}
/**
* Gets the intProperty attribute of the SourceDefinition class
*
* @param key Description of the Parameter
* @param defaultValue Description of the Parameter
* @return The intProperty value
*/
public final static int getIntProperty(String key, int defaultValue) {
String propStr = (String) projectProps.get(key);
int prop = 0;
if (propStr != null) {
prop = Integer.parseInt(propStr);
} else {
prop = defaultValue;
}
return prop;
}
/**
* Gets the booleanProperty attribute of the SourceDefinition class
*
* @param key Description of the Parameter
* @param defaultValue Description of the Parameter
* @return The booleanProperty value
*/
private final static boolean getBooleanProperty(String key, boolean defaultValue) {
String propStr = (String) projectProps.get(key);
boolean prop = false;
if (propStr != null) {
prop = new Boolean(propStr).booleanValue();
} else {
prop = defaultValue;
}
return prop;
}
/**
* Gets the stringProperty attribute of the SourceDefinition class
*
* @param key Description of the Parameter
* @param defaultValue Description of the Parameter
* @param allowedValues Description of the Parameter
* @return The stringProperty value
*/
private final static String getStringProperty(String key, String defaultValue,
String[] allowedValues) {
String prop = (String) projectProps.get(key);
//String prop = (String) projectProps.get(key,defaultValue);
System.out.println("key = " + key + " val = " + prop + " default " +
defaultValue + " allowed = " + allowedValues);
if (prop == null) {
prop = defaultValue;
}
if (allowedValues != null) {
List list = Arrays.asList(allowedValues);
if (!list.contains(prop)) {
StringBuffer sb = new StringBuffer("unrecognised value: ");
sb.append(prop);
sb.append(" for property: ");
sb.append(key);
sb.append(" allowed values are: ");
for (int i = 0; i < allowedValues.length; i++) {
sb.append(allowedValues[i]);
if (i < (allowedValues.length - 1)) {
sb.append(",");
}
}
throw new BuildException(sb.toString());
}
}
return prop;
}
/**
* Gets the fileProperty attribute of the SourceDefinition class
*
* @param key Description of the Parameter
* @param defaultValue Description of the Parameter
* @return The fileProperty value
*/
private final static File getFileProperty(String key, String defaultValue) {
String prop = (String) projectProps.get(key);
if (prop == null) {
prop = defaultValue;
}
return new File(prop);
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>