PR: MPJALOPY-10

Complete rewrite of the plugin so it doesn't use the jalopy ant task anymore.
Using a jellybean instead, copied and adapted from the m2 jalopy plugin at mojo.
Added new properties maven.jalopy.inspect, maven.jalopy.backup and maven.jalopy.force.
Removed properties maven.jalopy.logLevel and maven.jalopy.nbThread.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@398096 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
ltheussl committed 2006-04-29 06:05:18 +00:00
1 parent d2011e6d90
commit 7551c043f3
19 files changed
+1991 -361

No files matched your search

-13
View File
@@ -1,13 +0,0 @@
A simple plugin to make jalopy available to you.
Your maven.xml might look something like this:
<goal name="format" prereqs="jalopy:taskdef">
<jalopy fileformat="unix"
loglevel="info"
threads="2">
<fileset dir="src/test" >
<include name="**/*.java" />
</fileset>
</jalopy>
</goal>
+26 -41
View File
@@ -20,59 +20,44 @@
<project
xmlns:ant="jelly:ant"
xmlns:define="jelly:define"
xmlns:jalopy="jalopy"
xmlns:j="jelly:core">
<!--==================================================================-->
<!-- J A L O P Y (source code formatter) -->
<!--==================================================================-->
<define:taglib uri="jalopy">
<define:jellybean
name="jalopy"
className="org.apache.maven.jalopy.JalopyBean"
method="execute"/>
</define:taglib>
<goal name="jalopy"
description="Format all sources with code convention conformance"
prereqs="jalopy:format"/>
<goal name="jalopy:taskdef"
description="Define the jalopy task to Ant and Jelly">
<ant:taskdef name="jalopy"
classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
<ant:classpath>
<ant:pathelement path="${plugin.getDependencyPath('jalopy')}"/>
<ant:pathelement path="${plugin.getDependencyPath('jalopy:jalopy-ant')}"/>
<ant:pathelement path="${plugin.getDependencyPath('aelfred')}"/>
<ant:pathelement path="${plugin.getDependencyPath('jdom')}"/>
<ant:pathelement path="${plugin.getDependencyPath('log4j')}"/>
<ant:pathelement path="${plugin.getDependencyPath('oro')}"/>
<ant:pathelement path="${plugin.getDependencyPath('textarea')}"/>
</ant:classpath>
</ant:taskdef>
</goal>
<goal name="jalopy:format"
description="Format all sources with code convention conformance"
prereqs="jalopy:taskdef, java:compile">
description="Format all sources with code convention conformance">
<jalopy:jalopy
fileFormat="${maven.jalopy.fileFormat}"
convention="${maven.jalopy.style}"
historyPolicy="${maven.jalopy.history}"
failOnError="${maven.jalopy.failOnError}"
inspect="${maven.jalopy.inspect}"
backup="${maven.jalopy.backup}"
force="${maven.jalopy.force}"
sourceDirectory="${pom.build.sourceDirectory}"
testSourceDirectory="${pom.build.unitTestSourceDirectory}"
srcIncludesPattern="${maven.jalopy.src.filesetInclude}"
srcExcludesPattern="${maven.jalopy.src.filesetExclude}"
testIncludesPattern="${maven.jalopy.test.filesetInclude}"
testExcludesPattern="${maven.jalopy.test.filesetExclude}"/>
<ant:path id="project.classpath">
<ant:path refid="maven.dependency.classpath"/>
<ant:pathelement path="${maven.build.dest}"/>
</ant:path>
<ant:jalopy fileformat="${maven.jalopy.fileFormat}"
style="${maven.jalopy.style}"
history="${maven.jalopy.history}"
loglevel="${maven.jalopy.logLevel}"
failonerror="${maven.jalopy.failOnError}"
threads="${maven.jalopy.nbThread}"
classpathref="project.classpath">
<j:if test="${sourcesPresent == 'true'}">
<ant:fileset dir="${pom.build.sourceDirectory}"
includes="${maven.jalopy.src.filesetInclude}"
excludes="${maven.jalopy.src.filesetExclude}"/>
</j:if>
<j:if test="${unitTestSourcesPresent == 'true'}">
<ant:fileset dir="${pom.build.unitTestSourceDirectory}"
includes="${maven.jalopy.test.filesetInclude}"
excludes="${maven.jalopy.test.filesetExclude}"/>
</j:if>
</ant:jalopy>
</goal>
</project>
+4 -3
View File
@@ -19,11 +19,12 @@
# -------------------------------------------------------------------
maven.jalopy.fileFormat=auto
maven.jalopy.style=${plugin.resources}/jalopy_maven.xml
maven.jalopy.style=${plugin.resources}/jalopy.xml
maven.jalopy.history=none
maven.jalopy.logLevel=info
maven.jalopy.nbThread=1
maven.jalopy.failOnError=true
maven.jalopy.inspect=false
maven.jalopy.backup=false
maven.jalopy.force=false
maven.jalopy.filesetInclude=**/*.java
maven.jalopy.filesetExclude=
+32 -33
View File
@@ -87,37 +87,20 @@
<groupId>jalopy</groupId>
<artifactId>jalopy</artifactId>
<version>1.5b5</version>
<properties>
<classloader>root</classloader>
</properties>
</dependency>
<dependency>
<groupId>jalopy</groupId>
<artifactId>jalopy-ant</artifactId>
<version>0.1-1.5b5</version>
<properties>
<classloader>root</classloader>
</properties>
<groupId>plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>aelfred</groupId>
<artifactId>aelfred</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.3.03</version>
<url>http://xml.apache.org/commons/</url>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
<properties>
<comment>This library is already loaded by maven's core. Be careful to use the same version number as in the core.</comment>
</properties>
</dependency>
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
@@ -126,15 +109,31 @@
<comment>This library is already loaded by maven's core. Be careful to use the same version number as in the core.</comment>
</properties>
</dependency>
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>textarea</groupId>
<artifactId>textarea</artifactId>
<version>2.2.3</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<unitTestSourceDirectory>src/test/java</unitTestSourceDirectory>
<unitTest>
<resources>
<resource>
<targetPath>input-bak</targetPath>
<directory>src/test/resources/input-bak</directory>
<includes>
<include>*.java</include>
</includes>
</resource>
<resource>
<targetPath>validator</targetPath>
<directory>src/test/resources/validator</directory>
<includes>
<include>*.java</include>
</includes>
</resource>
</resources>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>
</build>
</project>
@@ -0,0 +1,564 @@
package org.apache.maven.jalopy;
/* ====================================================================
* Copyright 2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import de.hunsicker.jalopy.Jalopy;
import de.hunsicker.jalopy.storage.Convention;
import de.hunsicker.jalopy.storage.History;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.StringUtils;
/**
* A bean to format all source files according to code conventions.
*
* @author jruiz@exist.com
* @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
* @author <a href="mailto:ltheussl@apache.org">Lukas Theussl</a>
* @version $Id$
*/
public class JalopyBean
{
/** Log. */
private static final Log LOG = LogFactory.getLog( JalopyBean.class );
/**
* Sets the file format of the output files.
* The file format controls what end of line character is used.
* Either one of "UNIX", "DOS", "MAC", "DEFAULT" or "AUTO" can be used.
*/
private String fileFormat;
/**
* Specifies the history policy to use.
* Either one of "COMMENT", "FILE" or "NONE" can be used.
*/
private String historyPolicy;
/**
* Indicates whether a run should be held if errors occured.
*/
private boolean failOnError;
/**
* Indicates whether to enable the code inspector.
*/
private boolean inspect;
/**
* Indicates whether keep backups of formatted source files.
*/
private boolean backup;
/**
* Indicates whether to force formatting of source files.
*/
private boolean force;
/**
* The source directory.
*/
private File sourceDirectory;
/**
* The test source directory.
*/
private File testSourceDirectory;
/**
* Sets the preferences file to use - given either relative to
* the project's basedir or as an absolute local path or internet address.
* If omitted, the current preferences are used, if available.
* Otherwise the Jalopy build-in defaults will be used.
*/
private File convention;
/**
* For Source Directory. Specifies a fileset source file to format.
* This is a comma- or space-separated list of patterns of files.
*/
private String srcIncludesPattern;
/**
* For Source Directory. Source files excluded from format.
* This is a comma- or space-separated list of patterns of files.
*/
private String srcExcludesPattern;
/**
* For Test Directory. Specifies a fileset source file to format.
* This is a comma- or space-separated list of patterns of files.
*/
private String testIncludesPattern;
/**
* For Test Directory. Source files excluded from format.
* This is a comma- or space-separated list of patterns of files.
*/
private String testExcludesPattern;
/**
* The main method: starts formatting of source files.
*
* @throws Exception Exception
*/
public void execute() throws Exception
{
LOG.info("[jalopy] Jalopy Java Source Code Formatter " + Jalopy.getVersion());
try
{
if ( getSourceDirectory().exists() )
{
String[] filesToFormat = getIncludedFiles( getSourceDirectory(), getSrcIncludesPattern(),
getSrcExcludesPattern() );
LOG.info( "[jalopy] Format " + filesToFormat.length + " source files in " + getSourceDirectory().toString() );
formatFiles( getSourceDirectory(), filesToFormat );
LOG.info( "[jalopy] " + filesToFormat.length + " source files formatted" );
}
if ( getTestSourceDirectory().exists() )
{
String[] filesToFormat = getIncludedFiles( getTestSourceDirectory(), getTestIncludesPattern(),
getTestExcludesPattern() );
LOG.info( "[jalopy] Format " + filesToFormat.length + " source files in " + getTestSourceDirectory().toString() );
formatFiles( getTestSourceDirectory(), filesToFormat );
LOG.info( "[jalopy] " + filesToFormat.length + " source files formatted" );
}
}
catch ( Exception e )
{
e.printStackTrace();
}
}
/**
* Returns a string array of files to format.
*
* @param directory The base directory
* @param includes The includes pattern
* @param excludes The excludes pattern
* @return String[]
*/
private String[] getIncludedFiles( File directory, String includes, String excludes )
{
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( directory );
scanner.setIncludes( StringUtils.split( includes, "," ) );
scanner.setExcludes( StringUtils.split( excludes, "," ) );
scanner.scan();
String[] filesToFormat = scanner.getIncludedFiles();
return filesToFormat;
}
/**
* Formats the source files.
*
* @param directory The base directory
* @param filesToFormat A string array of files to format
* @throws FileNotFoundException FileNotFoundException
* @throws Exception Exception
*/
private void formatFiles( File directory, String[] filesToFormat )
throws FileNotFoundException, Exception
{
Jalopy jalopy = createJalopy();
for ( int i = 0; i < filesToFormat.length; i++ )
{
File currentFile = new File( directory, filesToFormat[i] );
jalopy.setInput( currentFile );
jalopy.setOutput( currentFile );
if ( isBackup() )
{
jalopy.setBackupDirectory( currentFile.getParentFile() );
}
jalopy.format();
logMessage( jalopy, currentFile );
}
}
/**
* Logs a message depending on the jalopy exit status.
*
* @param jalopy The jalopy instance
* @param currentFile The file whose status is to be logged
* @throws Exception Exception
*/
private void logMessage( Jalopy jalopy, File currentFile )
throws Exception
{
if ( jalopy.getState() == Jalopy.State.OK )
{
LOG.debug( "[jalopy] " + currentFile + " formatted correctly." );
}
else if ( jalopy.getState() == Jalopy.State.WARN )
{
LOG.warn( "[jalopy] " + currentFile + " formatted with warnings." );
}
else if ( jalopy.getState() == Jalopy.State.ERROR )
{
LOG.error( "[jalopy] " + currentFile + " could not be formatted." );
if ( isFailOnError() )
{
throw new Exception( currentFile + " could not be formatted." );
}
}
else
{
LOG.warn( "[jalopy] " + currentFile + " formatted with unknown state." );
}
}
/**
* Creates a new instance of a Jalopy formatter with all bean variables being set.
*
* @return Jalopy
*/
private Jalopy createJalopy()
{
Jalopy jalopy = new Jalopy();
try
{
if ( ( convention != null ) && convention.exists() )
{
LOG.debug( "[jalopy] Using convention file : " + convention.getAbsoluteFile() );
Jalopy.setConvention( convention );
}
else
{
LOG.warn( "[jalopy] Convention file does not exist: " + convention.getAbsoluteFile() );
LOG.warn( "[jalopy] Using default convention : jalopy.xml");
InputStream in = this.getClass().getClassLoader().getResourceAsStream( "plugin-resources/jalopy.xml" );
Convention.importSettings( in, Convention.EXTENSION_XML );
}
}
catch ( IOException ex )
{
ex.printStackTrace();
}
jalopy.setFileFormat( getFileFormat() );
jalopy.setInspect( isInspect() );
if ( !getHistoryPolicy().equalsIgnoreCase( "none" ) )
{
jalopy.setHistoryPolicy( History.Policy.valueOf( getHistoryPolicy() ) );
}
// TODO: what are the allowed values for historyMethod?
//Convention settings = Convention.getInstance();
//History.Method historyMethod = History.Method.valueOf( settings.get( ConventionKeys.HISTORY_METHOD,
// ConventionDefaults.HISTORY_METHOD ) );
//jalopy.setHistoryMethod( historyMethod );
jalopy.setBackup( isBackup() );
jalopy.setForce( isForce() );
return jalopy;
}
/**
* Returns the fileFormat property.
*
* @return String
*/
public String getFileFormat()
{
return fileFormat;
}
/**
* Sets the fileFormat property.
*
* @param newfileFormat The new property
*/
public void setFileFormat( String newfileFormat )
{
this.fileFormat = newfileFormat;
}
/**
* Returns the failOnError property.
*
* @return boolean
*/
public boolean isFailOnError()
{
return failOnError;
}
/**
* Sets the failOnError property.
*
* @param newfailOnError The new property
*/
public void setFailOnError( boolean newfailOnError )
{
this.failOnError = newfailOnError;
}
/**
* Returns the inspect property.
*
* @return boolean
*/
public boolean isInspect()
{
return inspect;
}
/**
* Sets the inspect property.
*
* @param newinspect The new property
*/
public void setInspect( boolean newinspect )
{
this.inspect = newinspect;
}
/**
* Returns the backup property.
*
* @return boolean
*/
public boolean isBackup()
{
return backup;
}
/**
* Sets the backup property.
*
* @param newbackup The new property
*/
public void setBackup( boolean newbackup )
{
this.backup = newbackup;
}
/**
* Returns the force property.
*
* @return boolean
*/
public boolean isForce()
{
return force;
}
/**
* Sets the force property.
*
* @param newforce The new property
*/
public void setForce( boolean newforce )
{
this.force = newforce;
}
/**
* Returns the sourceDirectory property.
*
* @return File
*/
public File getSourceDirectory()
{
return sourceDirectory;
}
/**
* Sets the sourceDirectory property.
*
* @param newsourceDirectory The new property
*/
public void setSourceDirectory( File newsourceDirectory )
{
this.sourceDirectory = newsourceDirectory;
}
/**
* Returns the srcIncludesPattern property.
*
* @return String
*/
public String getSrcIncludesPattern()
{
return srcIncludesPattern;
}
/**
* Sets the srcIncludesPattern property.
*
* @param newsrcIncludesPattern The new property
*/
public void setSrcIncludesPattern( String newsrcIncludesPattern )
{
this.srcIncludesPattern = newsrcIncludesPattern;
}
/**
* Returns the srcExcludesPattern property.
*
* @return String
*/
public String getSrcExcludesPattern()
{
return srcExcludesPattern;
}
/**
* Sets the srcExcludesPattern property.
*
* @param newsrcExcludesPattern The new property
*/
public void setSrcExcludesPattern( String newsrcExcludesPattern )
{
this.srcExcludesPattern = newsrcExcludesPattern;
}
/**
* Returns the historyPolicy property.
*
* @return String
*/
public String getHistoryPolicy()
{
return historyPolicy;
}
/**
* Sets the historyPolicy property.
*
* @param newhistoryPolicy The new property
*/
public void setHistoryPolicy( String newhistoryPolicy )
{
this.historyPolicy = newhistoryPolicy;
}
/**
* Returns the convention property.
*
* @return File
*/
public File getConvention()
{
return convention;
}
/**
* Sets the convention property.
*
* @param newconvention The new property
*/
public void setConvention( File newconvention )
{
this.convention = newconvention;
}
/**
* Returns the testSourceDirectory property.
*
* @return File
*/
public File getTestSourceDirectory()
{
return testSourceDirectory;
}
/**
* Sets the testSourceDirectory property.
*
* @param newtestSourceDirectory The new property
*/
public void setTestSourceDirectory( File newtestSourceDirectory )
{
this.testSourceDirectory = newtestSourceDirectory;
}
/**
* Returns the testIncludesPattern property.
*
* @return String
*/
public String getTestIncludesPattern()
{
return testIncludesPattern;
}
/**
* Sets the testIncludesPattern property.
*
* @param newtestIncludesPattern The new property
*/
public void setTestIncludesPattern( String newtestIncludesPattern )
{
this.testIncludesPattern = newtestIncludesPattern;
}
/**
* Returns the testExcludesPattern property.
*
* @return String
*/
public String getTestExcludesPattern()
{
return testExcludesPattern;
}
/**
* Sets the testExcludesPattern property.
*
* @param newtestExcludesPattern The new property
*/
public void setTestExcludesPattern( String newtestExcludesPattern )
{
this.testExcludesPattern = newtestExcludesPattern;
}
}
@@ -0,0 +1,11 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>org.apache.maven.jalopy</title>
</head>
<body>
<p>
Contains classes to format java source files with jalopy.
</p>
</body>
</html>
+385
View File
@@ -0,0 +1,385 @@
<?xml version="1.0" encoding="UTF-8"?>
<jalopy>
<general>
<compliance>
<version>13</version>
</compliance>
<style>
<description>Maven 2</description>
<name>Maven2</name>
</style>
</general>
<inspector>
<enable>false</enable>
<naming>
<classes>
<abstract>[A-Z][a-zA-Z0-9]+</abstract>
<general>[A-Z][a-zA-Z0-9]+</general>
</classes>
<fields>
<default>[a-z][\w]+</default>
<defaultStatic>[a-z][\w]+</defaultStatic>
<defaultStaticFinal>[a-zA-Z][\w]+</defaultStaticFinal>
<private>[a-z][\w]+</private>
<privateStatic>[a-z][\w]+</privateStatic>
<privateStaticFinal>[a-zA-Z][\w]+</privateStaticFinal>
<protected>[a-z][\w]+</protected>
<protectedStatic>[a-z][\w]+</protectedStatic>
<protectedStaticFinal>[a-zA-Z][\w]+</protectedStaticFinal>
<public>[a-z][\w]+</public>
<publicStatic>[a-z][\w]+</publicStatic>
<publicStaticFinal>[a-zA-Z][\w]+</publicStaticFinal>
</fields>
<interfaces>[A-Z][a-zA-Z0-9]+</interfaces>
<labels>\w+</labels>
<methods>
<default>[a-z][\w]+</default>
<defaultStatic>[a-z][\w]+</defaultStatic>
<defaultStaticFinal>[a-z][\w]+</defaultStaticFinal>
<private>[a-z][\w]+</private>
<privateStatic>[a-z][\w]+</privateStatic>
<privateStaticFinal>[a-z][\w]+</privateStaticFinal>
<protected>[a-z][\w]+</protected>
<protectedStatic>[a-z][\w]+</protectedStatic>
<protectedStaticFinal>[a-z][\w]+</protectedStaticFinal>
<public>[a-z][\w]+</public>
<publicStatic>[a-z][\w]+</publicStatic>
<publicStaticFinal>[a-z][\w]+</publicStaticFinal>
</methods>
<packages>[a-z]+(?:\.[a-z]+)*</packages>
<parameters>
<default>[a-z][\w]+</default>
<final>[a-z][\w]+</final>
</parameters>
<variables>[a-z][\w]*</variables>
</naming>
<tips>
<adhereToNamingConvention>false</adhereToNamingConvention>
<alwaysOverrideHashCode>false</alwaysOverrideHashCode>
<avoidThreadGroups>false</avoidThreadGroups>
<declareCollectionComment>false</declareCollectionComment>
<dontIgnoreExceptions>false</dontIgnoreExceptions>
<dontSubstituteObjectEquals>false</dontSubstituteObjectEquals>
<neverDeclareException>false</neverDeclareException>
<neverDeclareThrowable>false</neverDeclareThrowable>
<neverInvokeWaitOutsideLoop>false</neverInvokeWaitOutsideLoop>
<neverReturnZeroArrays>false</neverReturnZeroArrays>
<neverUseEmptyFinally>false</neverUseEmptyFinally>
<obeyContractEquals>false</obeyContractEquals>
<overrideToString>false</overrideToString>
<referToObjectsByInterface>false</referToObjectsByInterface>
<replaceStructureWithClass>false</replaceStructureWithClass>
<stringLiterallI18n>false</stringLiterallI18n>
<useInterfaceOnlyForTypes>false</useInterfaceOnlyForTypes>
<wrongCollectionComment>false</wrongCollectionComment>
</tips>
</inspector>
<internal>
<version>6</version>
</internal>
<messages>
<priority>
<general>30000</general>
<parser>30000</parser>
<parserJavadoc>30000</parserJavadoc>
<printer>30000</printer>
<printerJavadoc>30000</printerJavadoc>
<transform>30000</transform>
</priority>
<showErrorStackTrace>true</showErrorStackTrace>
</messages>
<misc>
<threadCount>2</threadCount>
</misc>
<printer>
<alignment>
<methodCallChain>true</methodCallChain>
<parameterMethodDeclaration>false</parameterMethodDeclaration>
<ternaryOperator>true</ternaryOperator>
<variableAssignment>false</variableAssignment>
<variableIdentifier>false</variableIdentifier>
</alignment>
<backup>
<directory>bak</directory>
<level>0</level>
</backup>
<blanklines>
<after>
<block>1</block>
<braceLeft>0</braceLeft>
<class>1</class>
<declaration>0</declaration>
<footer>1</footer>
<header>0</header>
<interface>1</interface>
<lastImport>1</lastImport>
<method>1</method>
<package>1</package>
</after>
<before>
<block>1</block>
<braceRight>0</braceRight>
<caseBlock>1</caseBlock>
<comment>
<javadoc>1</javadoc>
<multiline>1</multiline>
<singleline>1</singleline>
</comment>
<controlStatement>1</controlStatement>
<declaration>1</declaration>
<footer>0</footer>
<header>2</header>
</before>
<keepUpTo>1</keepUpTo>
</blanklines>
<braces>
<empty>
<cuddle>false</cuddle>
<insertStatement>false</insertStatement>
</empty>
<insert>
<dowhile>true</dowhile>
<for>true</for>
<ifelse>true</ifelse>
<while>true</while>
</insert>
<remove>
<block>true</block>
<dowhile>false</dowhile>
<for>false</for>
<ifelse>false</ifelse>
<while>false</while>
</remove>
<treatDifferent>
<methodClass>true</methodClass>
<methodClassIfWrapped>true</methodClassIfWrapped>
</treatDifferent>
</braces>
<chunks>
<blanklines>true</blanklines>
<comments>true</comments>
</chunks>
<comments>
<format>
<multiline>false</multiline>
</format>
<javadoc>
<check>
<innerclass>false</innerclass>
<tags>false</tags>
<throwsTags>true</throwsTags>
</check>
<fieldsShort>false</fieldsShort>
<generate>
<class>0</class>
<constructor>0</constructor>
<field>0</field>
<method>0</method>
</generate>
<parseComments>false</parseComments>
<tags>
<in-line />
<standard />
</tags>
<templates>
<class>/**| * DOCUMENT ME!| *| * @author $author$| * @version $Revision: 120 $| */</class>
<constructor>
<bottom> */</bottom>
<exception> * @throws $exceptionType$ DOCUMENT ME!</exception>
<param> * @param $paramType$ DOCUMENT ME!</param>
<top>/**| * Creates a new $objectType$ object.</top>
</constructor>
<interface>/**| * DOCUMENT ME!| *| * @author $author$| * @version $Revision: 120 $| */</interface>
<method>
<bottom> */</bottom>
<exception> * @throws $exceptionType$ DOCUMENT ME!</exception>
<param> * @param $paramType$ DOCUMENT ME!</param>
<return> * @return DOCUMENT ME!</return>
<top>/**| * DOCUMENT ME!</top>
</method>
</templates>
</javadoc>
<remove>
<javadoc>false</javadoc>
<multiline>false</multiline>
<singleline>false</singleline>
</remove>
<separator>
<fillCharacter>-</fillCharacter>
<insert>false</insert>
<insertRecursive>false</insertRecursive>
<text>
<class>Inner Classes</class>
<constructor>Constructors</constructor>
<field>Instance fields</field>
<initializer>Instance initializers</initializer>
<interface>Inner Interfaces</interface>
<method>Methods</method>
<static>Static fields/initializers</static>
</text>
</separator>
</comments>
<environment />
<footer>
<keys />
<smartMode>0</smartMode>
<use>false</use>
</footer>
<header>
<keys>Tha Apache Software License</keys>
<smartMode>5</smartMode>
<text>/*| * Copyright 2001-2004 The Apache Software Foundation.| *| * Licensed under the Apache License, Version 2.0 (the "License");| * you may not use this file except in compliance with the License.| * You may obtain a copy of the License at| *| * http://www.apache.org/licenses/LICENSE-2.0| *| * Unless required by applicable law or agreed to in writing, software| * distributed under the License is distributed on an "AS IS" BASIS,| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.| * See the License for the specific language governing permissions and| * limitations under the License.| */</text>
<use>false</use>
</header>
<history>
<policy>disabled</policy>
</history>
<imports>
<grouping>
<defaultDepth>3</defaultDepth>
<packages>*:0|gnu:2|java:1|javax:1</packages>
</grouping>
<policy>disabled</policy>
<sort>true</sort>
</imports>
<indentation>
<caseFromSwitch>true</caseFromSwitch>
<continuation>
<block>true</block>
<operator>false</operator>
</continuation>
<firstColumnComments>false</firstColumnComments>
<label>false</label>
<policy>
<deep>true</deep>
</policy>
<sizes>
<braceCuddled>1</braceCuddled>
<braceLeft>0</braceLeft>
<braceRight>0</braceRight>
<braceRightAfter>1</braceRightAfter>
<continuation>4</continuation>
<deep>55</deep>
<extends>-1</extends>
<general>4</general>
<implements>-1</implements>
<leading>0</leading>
<tabs>8</tabs>
<throws>-1</throws>
<trailingComment>1</trailingComment>
</sizes>
<tabs>
<enable>false</enable>
<onlyLeading>false</onlyLeading>
</tabs>
</indentation>
<misc>
<arrayBracketsAfterIdent>false</arrayBracketsAfterIdent>
<forceFormatting>false</forceFormatting>
<insertExpressionParentheses>true</insertExpressionParentheses>
<insertLoggingConditional>false</insertLoggingConditional>
<insertTrailingNewline>true</insertTrailingNewline>
<insertUID>false</insertUID>
</misc>
<sorting>
<declaration>
<class>false</class>
<constructor>false</constructor>
<enable>false</enable>
<interface>false</interface>
<method>false</method>
<order>static|field|initializer|constructor|method|interface|class</order>
<variable>false</variable>
</declaration>
<modifier>
<enable>false</enable>
<order>public|protected|private|abstract|static|final|synchronized|transient|volatile|native|strictfp</order>
</modifier>
</sorting>
<whitespace>
<after>
<comma>true</comma>
<semicolon>true</semicolon>
<typeCast>true</typeCast>
</after>
<before>
<braces>true</braces>
<brackets>false</brackets>
<bracketsTypes>false</bracketsTypes>
<caseColon>false</caseColon>
<operator>
<not>true</not>
</operator>
<parentheses>
<methodCall>false</methodCall>
<methodDeclaration>false</methodDeclaration>
<statement>true</statement>
</parentheses>
</before>
<padding>
<braces>true</braces>
<brackets>false</brackets>
<operator>
<assignment>true</assignment>
<bitwise>true</bitwise>
<logical>true</logical>
<mathematical>true</mathematical>
<relational>true</relational>
<shift>true</shift>
</operator>
<parenthesis>true</parenthesis>
<typeCast>false</typeCast>
</padding>
</whitespace>
<wrapping>
<always>
<after>
<arrayElement>0</arrayElement>
<braceRight>false</braceRight>
<extendsTypes>false</extendsTypes>
<implementsTypes>false</implementsTypes>
<label>true</label>
<methodCallChained>false</methodCallChained>
<ternaryOperator>
<first>false</first>
<second>false</second>
</ternaryOperator>
<throwsTypes>false</throwsTypes>
</after>
<before>
<braceLeft>true</braceLeft>
<extends>true</extends>
<implements>true</implements>
<throws>true</throws>
</before>
<parameter>
<methodCall>false</methodCall>
<methodCallNested>true</methodCallNested>
<methodDeclaration>false</methodDeclaration>
</parameter>
</always>
<general>
<beforeOperator>false</beforeOperator>
<enable>true</enable>
<lineLength>120</lineLength>
</general>
<ondemand>
<after>
<assignment>true</assignment>
<leftParenthesis>false</leftParenthesis>
<parameter>true</parameter>
<types>
<extends>true</extends>
<implements>true</implements>
<throws>true</throws>
</types>
</after>
<before>
<rightParenthesis>false</rightParenthesis>
</before>
<groupingParentheses>true</groupingParentheses>
</ondemand>
</wrapping>
</printer>
</jalopy>
@@ -1,254 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<jalopy>
<printer>
<alignment>
<ParamsMethodDef>false</ParamsMethodDef>
<varAssigns>false</varAssigns>
<varIdents>false</varIdents>
<ternaryExpresssion>false</ternaryExpresssion>
<ternaryValue>false</ternaryValue>
</alignment>
<sorting>
<variable>false</variable>
<class>false</class>
<modifiers>
<use>false</use>
</modifiers>
<method>false</method>
<order>Static Variables/Initializers,Instance Variables,Instance Initializers,Constructors,Methods,Interfaces,Classes</order>
<use>true</use>
<constructor>false</constructor>
<orderModifiers>public,protected,private,abstract,static,final,synchronized,transient,volatile,native,strictfp</orderModifiers>
<interface>false</interface>
</sorting>
<blankLines>
<beforeHeader>0</beforeHeader>
<beforeCommentSingleLine>1</beforeCommentSingleLine>
<afterLastImport>1</afterLastImport>
<afterPackage>1</afterPackage>
<afterClass>1</afterClass>
<beforeControl>1</beforeControl>
<afterBraceLeft>0</afterBraceLeft>
<keepUpTo>1</keepUpTo>
<beforeJavadoc>1</beforeJavadoc>
<beforeCommentMultiLine>1</beforeCommentMultiLine>
<afterDeclaration>1</afterDeclaration>
<afterInterface>1</afterInterface>
<afterMethod>1</afterMethod>
<afterBlock>1</afterBlock>
<beforeBlock>1</beforeBlock>
<beforeDeclaration>1</beforeDeclaration>
<afterFooter>0</afterFooter>
<afterHeader>1</afterHeader>
<beforeBraceRight>0</beforeBraceRight>
<beforeCaseBlock>1</beforeCaseBlock>
<beforeFooter>0</beforeFooter>
</blankLines>
<header>
<text>/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/</text>
<smartModeLines>5</smartModeLines>
<keys>The Apache Software License</keys>
<use>false</use>
</header>
<whitespace>
<paddingLogicalOperators>true</paddingLogicalOperators>
<beforeMethodDeclarationParenthesis>false</beforeMethodDeclarationParenthesis>
<paddingBrackets>false</paddingBrackets>
<afterComma>true</afterComma>
<paddingBitwiseOperators>true</paddingBitwiseOperators>
<paddingAssignmentOperators>true</paddingAssignmentOperators>
<beforeLogicalNot>false</beforeLogicalNot>
<padddingTypeCast>false</padddingTypeCast>
<paddingRelationalOperators>true</paddingRelationalOperators>
<beforeStatementParenthesis>true</beforeStatementParenthesis>
<afterCastingParenthesis>true</afterCastingParenthesis>
<beforeBraces>true</beforeBraces>
<beforeCaseColon>false</beforeCaseColon>
<paddingMathematicalOperators>true</paddingMathematicalOperators>
<paddingBraces>true</paddingBraces>
<beforeMethodCallParenthesis>false</beforeMethodCallParenthesis>
<afterSemiColon>true</afterSemiColon>
<beforeBracketsTypes>false</beforeBracketsTypes>
<padddingParenthesis>false</padddingParenthesis>
<paddingShiftOperators>true</paddingShiftOperators>
<beforeBrackets>false</beforeBrackets>
</whitespace>
<indentation>
<label>false</label>
<braceRightAfter>0</braceRightAfter>
<extends>-1</extends>
<implements>-1</implements>
<leading>0</leading>
<continationIf>false</continationIf>
<parameter>-1</parameter>
<general>4</general>
<commentEndline>1</commentEndline>
<firstColumnComments>true</firstColumnComments>
<continationIfTernary>false</continationIfTernary>
<tabs>
<size>4</size>
<use>false</use>
</tabs>
<caseFromSwitch>false</caseFromSwitch>
<throws>-1</throws>
<braceLeft>1</braceLeft>
<deep>30</deep>
<braceRight>0</braceRight>
<useMethodCallParams>false</useMethodCallParams>
<continuation>4</continuation>
<braceCuddled>1</braceCuddled>
</indentation>
<comments>
<javadoc>
<addField>0</addField>
<remove>false</remove>
<templates>
<methods>
<return> * @return DOCUMENT ME!</return>
<exception> * @throws $exceptionType$ DOCUMENT ME!</exception>
<top>/**| * DOCUMENT ME!</top>
<bottom> */</bottom>
<param> * @param $paramType$ DOCUMENT ME!</param>
</methods>
</templates>
<tags>
<in-line />
<standard />
</tags>
<addClass>0</addClass>
<checkInnerClass>false</checkInnerClass>
<addCtor>0</addCtor>
<addMethod>0</addMethod>
<parseComments>false</parseComments>
<checkTags>false</checkTags>
</javadoc>
<separator>
<method>Methods</method>
<staticVariableInit>Static variables/initializers</staticVariableInit>
<ctor>Constructors</ctor>
<fillCharacter>·</fillCharacter>
<interface>Interfaces</interface>
<instanceInit>Instance initializers</instanceInit>
<instanceVariable>Instance variables</instanceVariable>
<class>Classes</class>
</separator>
<formatMultiLine>false</formatMultiLine>
<insertSeparatorRecursive>false</insertSeparatorRecursive>
<insertSeparator>false</insertSeparator>
<removeMultiLine>false</removeMultiLine>
<removeSingleLine>false</removeSingleLine>
</comments>
<footer>
<keys />
<text />
<use>false</use>
<smartModeLines>0</smartModeLines>
</footer>
<wrapping>
<arrayElements>0</arrayElements>
<afterThrowsTypes>false</afterThrowsTypes>
<afterImplementsTypes>false</afterImplementsTypes>
<beforeThrows>false</beforeThrows>
<afterChainedMethodCall>false</afterChainedMethodCall>
<afterExtendsTypes>false</afterExtendsTypes>
<paramsMethodCall>false</paramsMethodCall>
<lineLength>80</lineLength>
<beforeExtends>false</beforeExtends>
<beforeOperator>true</beforeOperator>
<paramsMethodDef>false</paramsMethodDef>
<beforeImplements>false</beforeImplements>
<paramsMethodCallIfCall>false</paramsMethodCallIfCall>
<afterLabel>true</afterLabel>
<use>true</use>
</wrapping>
<braces>
<removeBracesBlock>true</removeBracesBlock>
<emptyInsertStatement>false</emptyInsertStatement>
<treatMethodClassDifferent>false</treatMethodClassDifferent>
<insertBracesIfElse>true</insertBracesIfElse>
<removeBracesDoWhile>false</removeBracesDoWhile>
<insertBracesWhile>true</insertBracesWhile>
<removeBracesFor>false</removeBracesFor>
<insertBracesFor>true</insertBracesFor>
<removeBracesIfElse>false</removeBracesIfElse>
<removeBracesWhile>false</removeBracesWhile>
<rightBraceNewLine>true</rightBraceNewLine>
<leftBraceNewLine>false</leftBraceNewLine>
<emptyCuddle>false</emptyCuddle>
<insertBracesDoWhile>true</insertBracesDoWhile>
</braces>
<history>
<policy>History.Policy [disabled]</policy>
</history>
<environment />
<chunks>
<byComments>true</byComments>
<byBlankLines>true</byBlankLines>
</chunks>
</printer>
<transform>
<import>
<policy>ImportPolicy [expand]</policy>
<groupingDepth>1</groupingDepth>
<grouping>javax:2|java:2</grouping>
<sort>true</sort>
</import>
<misc>
<insertUID>false</insertUID>
<insertLoggingConditional>false</insertLoggingConditional>
<insertExpressionParenthesis>true</insertExpressionParenthesis>
</misc>
</transform>
<general>
<styleName>Sun</styleName>
<styleDescription>Sun Java Coding Convention</styleDescription>
<backupLevel>0</backupLevel>
<backupDirectory>bak</backupDirectory>
<threadCount>1</threadCount>
<sourceVersion>13</sourceVersion>
<forceFormatting>false</forceFormatting>
</general>
<messages>
<ioMsgPrio>30000</ioMsgPrio>
<parserMsgPrio>30000</parserMsgPrio>
<parserJavadocMsgPrio>30000</parserJavadocMsgPrio>
<printerMsgPrio>30000</printerMsgPrio>
<printerJavadocMsgPrio>30000</printerJavadocMsgPrio>
<showErrorStackTrace>true</showErrorStackTrace>
<transformMsgPrio>30000</transformMsgPrio>
</messages>
<internal>
<version>4</version>
</internal>
</jalopy>
@@ -0,0 +1,312 @@
package org.apache.maven.jalopy;
/* ====================================================================
* Copyright 2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.StringTokenizer;
/**
* Test case for JalopyBean.java
*
* @author <a href="mailto:jruiz@exist.com">Johnny R. Ruiz III</a>
* @author <a href="mailto:ltheussl@apache.org">Lukas Theussl</a>
* @version $Id$
*/
public class JalopyBeanTest extends TestCase
{
/** An instance of a JalopyBean. */
private JalopyBean jalopy;
/** The basedir system property. */
private String baseDir = System.getProperty( "basedir" );
/**
* Constructor.
*
* @param testName The name of the test.
*/
public JalopyBeanTest( String testName )
{
super( testName );
}
/** JUnit setUp.
* @throws Exception Exception
*/
protected void setUp() throws Exception
{
jalopy = new JalopyBean();
}
/** JUnit tearDown.
* @throws Exception Exception
*/
protected void tearDown() throws Exception
{
}
/**
* Rus the test suite.
*
* @return Test
*/
public static Test suite()
{
TestSuite suite = new TestSuite( JalopyBeanTest.class );
return suite;
}
/** Tests equality of not yet formatted files.
* @throws IOException IOException
*/
public void testIfInputFilesIsNotYetJalopyFormatted()
throws IOException
{
recopyInputFiles();
assertTrue( compareTextFiles( new File( baseDir, "target/test-classes/input/test/Circle.java" ),
new File( baseDir, "target/test-classes/input-bak/Circle.java" ) ) );
assertTrue( compareTextFiles( new File( baseDir, "target/test-classes/input/src/Rectangle.java" ),
new File( baseDir, "target/test-classes/input-bak/Rectangle.java" ) ) );
assertTrue( compareTextFiles( new File( baseDir, "target/test-classes/input/test/Point.java" ),
new File( baseDir, "target/test-classes/input-bak/Point.java" ) ) );
assertTrue( compareTextFiles( new File( baseDir, "target/test-classes/input/src/Point.java" ),
new File( baseDir, "target/test-classes/input-bak/Point.java" ) ) );
}
/** Tests not-equality of formatted files. */
public void testExecute()
{
jalopy.setFailOnError( true );
jalopy.setFileFormat( "auto" );
jalopy.setConvention( new File( baseDir, "src/test/resources/jalopy.xml" ) );
jalopy.setSourceDirectory( new File( baseDir, "target/test-classes/input/src" ) );
jalopy.setSrcExcludesPattern( "Point.java" );
jalopy.setSrcIncludesPattern( "Rectangle.java" );
jalopy.setTestSourceDirectory( new File( baseDir, "target/test-classes/input/test" ) );
jalopy.setTestExcludesPattern( "" );
jalopy.setTestIncludesPattern( "*.java" );
jalopy.setHistoryPolicy( "none" );
jalopy.setInspect( false );
jalopy.setForce( false );
jalopy.setBackup( false );
try
{
jalopy.execute();
assertFalse( compareTextFiles( new File( baseDir, "target/test-classes/input/test/Circle.java" ),
new File( baseDir, "target/test-classes/input-bak/Circle.java" ) ) );
assertFalse( compareTextFiles( new File( baseDir, "target/test-classes/input/src/Rectangle.java" ),
new File( baseDir, "target/test-classes/input-bak/Rectangle.java" ) ) );
assertFalse( compareTextFiles( new File( baseDir, "target/test-classes/input/test/Point.java" ),
new File( baseDir, "target/test-classes/input-bak/Point.java" ) ) );
assertTrue( compareTextFiles( new File( baseDir, "target/test-classes/input/src/Point.java" ),
new File( baseDir, "target/test-classes/input-bak/Point.java" ) ) );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
/** Test source input files.
* @throws IOException IOException
*/
public void testIfSourceInputFilesWasFormatted()
throws IOException
{
assertTrue( compareTextFiles( new File( baseDir, "target/test-classes/input/src/Rectangle.java" ),
new File( baseDir, "target/test-classes/validator/Rectangle.java" ) ) );
}
/** Test excludes pattern.
* @throws IOException IOException
*/
public void testIfExcludedFilesNotFormatted()
throws IOException
{
assertTrue( compareTextFiles( new File( baseDir, "target/test-classes/input/src/Point.java" ),
new File( baseDir, "target/test-classes/input-bak/Point.java" ) ) );
}
/** Test that all source input files are formatted.
* @throws IOException IOException
*/
public void testIfTestInputFilesAllFormatted()
throws IOException
{
assertTrue( compareTextFiles( new File( baseDir, "target/test-classes/input/test/Circle.java" ),
new File( baseDir, "target/test-classes/validator/Circle.java" ) ) );
assertTrue( compareTextFiles( new File( baseDir, "target/test-classes/input/test/Point.java" ),
new File( baseDir, "target/test-classes/validator/Point.java" ) ) );
assertTrue( compareTextFiles( new File( baseDir, "target/test-classes/input/test/Rectangle.java" ),
new File( baseDir, "target/test-classes/validator/Rectangle.java" ) ) );
}
/** Test fileFormat. */
public void testSetGetFileFormat()
{
jalopy.setFileFormat( "fileFormat" );
assertEquals( "fileFormat", jalopy.getFileFormat() );
}
/** Test FailOnError. */
public void testSetIsFailOnError()
{
jalopy.setFailOnError( true );
assertEquals( true, jalopy.isFailOnError() );
}
/** Test SourceDirectory. */
public void testSetGetSourceDirectory()
{
jalopy.setSourceDirectory( new File( "src/test" ) );
assertEquals( new File( "src/test" ), jalopy.getSourceDirectory() );
}
/** Test SrcIncludesPattern. */
public void testSetGetSrcIncludesPattern()
{
jalopy.setSrcIncludesPattern( "**.*" );
assertEquals( "**.*", jalopy.getSrcIncludesPattern() );
}
/** Test SrcExcludesPattern. */
public void testSetGetSrcExcludesPattern()
{
jalopy.setSrcExcludesPattern( "**.pro" );
assertEquals( "**.pro", jalopy.getSrcExcludesPattern() );
}
/** Test HistoryPolicy. */
public void testSetGetHistory()
{
jalopy.setHistoryPolicy( "history" );
assertEquals( "history", jalopy.getHistoryPolicy() );
}
/**
* Compares two text files for equality.
*
* @param f1 The first file
* @param f2 The second file
* @return True if the files are equal
* @throws FileNotFoundException FileNotFoundException
* @throws IOException IOException
*/
private boolean compareTextFiles( File f1, File f2 )
throws FileNotFoundException, IOException
{
String text1 = getTextContents( f1 );
String text2 = getTextContents( f2 );
StringTokenizer tokenizer1 = new StringTokenizer( text1, "\n" );
StringTokenizer tokenizer2 = new StringTokenizer( text2, "\n" );
if ( tokenizer1.countTokens() != tokenizer2.countTokens() )
{
return false;
}
while ( tokenizer1.hasMoreTokens() )
{
if ( !tokenizer1.nextToken().equalsIgnoreCase( tokenizer2.nextToken() ) )
{
return false;
}
}
return true;
}
/**
* Returns the text content of a file.
*
* @param f The file
* @return The file as a String
* @throws FileNotFoundException FileNotFoundException
* @throws IOException IOException
*/
private String getTextContents( File f )
throws FileNotFoundException, IOException
{
FileInputStream fIn = new FileInputStream( f );
byte[] fBytes = new byte[fIn.available()];
fIn.read( fBytes );
fIn.close();
return new String( fBytes );
}
/** Make a copy of input files so they can be compared several times.
* @throws IOException IOException
*/
private void recopyInputFiles()
throws IOException
{
FileUtils.copyDirectory( new File( baseDir, "src/test/resources/input-bak/" ),
new File( baseDir, "target/test-classes/input/src" ) );
FileUtils.copyDirectory( new File( baseDir, "src/test/resources/input-bak/" ),
new File( baseDir, "target/test-classes/input/test" ) );
}
}
@@ -0,0 +1,11 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>org.apache.maven.jalopy</title>
</head>
<body>
<p>
Test classes for org.apache.maven.jalopy.
</p>
</body>
</html>
@@ -0,0 +1,32 @@
package com.shape;
import java.io.File;
import java.lang.Math;
public class Circle extends Point
{
public final float PI = 3.1415926535897932385f;
public float Circumference; public int Diameter;
private int Radius;
public float getCircumference( ) {
Circumference = 2 * ( Radius * PI );
return Circumference; }
public int getDiameter( ) {
Diameter = Radius * 2;
return Diameter; }
public void setRadius( int intRadius )
{
this.Radius = intRadius; }
public int getRadius( )
{ return this.Radius;
}
public static void main( String[] args ) {
System.out.println( "Main Program for Junit Sample triggered!" ); }
}
@@ -0,0 +1,24 @@
package com.shape;
public class Point
{
private int x;
private int y;
public void setX( int xValue )
{
x = xValue;
}
public int getX( ) {
return this.x;
}
public void setY( int yValue ) {
y = yValue;
}
public int getY( ) {
return this.y;
}
}
@@ -0,0 +1,53 @@
package com.shape;
public class Rectangle
{
private float Hypotenuse;
private int Area;
private int Height;
private int Perimeter;
private int Width;
public int getArea( )
{
this.Area = this.Width * this.Height; return this.Area; }
public void setHeight( int height )
{
Height = height; }
public int getHeight( ) {
return this.Height;
}
public float getHypotenuse( ) {
this.Hypotenuse = (float) Math.sqrt( Math.pow( this.Height, 2.0 ) + Math.pow( this.Width, 2.0 ) );
return this.Hypotenuse;
}
public int getPerimeter( )
{
this.Perimeter = ( 2 * this.Width ) + ( 2 * this.Height );
return this.Perimeter; }
public void setWidth( int width ) {
Width = width; }
public int getWidth( ) {
return this.Width;
}
public void setWidthHeight( int width, int height )
{
setWidth( width );
setHeight( height );
}
}
+385
View File
@@ -0,0 +1,385 @@
<?xml version="1.0" encoding="UTF-8"?>
<jalopy>
<general>
<compliance>
<version>13</version>
</compliance>
<style>
<description>Maven 2</description>
<name>Maven2</name>
</style>
</general>
<inspector>
<enable>false</enable>
<naming>
<classes>
<abstract>[A-Z][a-zA-Z0-9]+</abstract>
<general>[A-Z][a-zA-Z0-9]+</general>
</classes>
<fields>
<default>[a-z][\w]+</default>
<defaultStatic>[a-z][\w]+</defaultStatic>
<defaultStaticFinal>[a-zA-Z][\w]+</defaultStaticFinal>
<private>[a-z][\w]+</private>
<privateStatic>[a-z][\w]+</privateStatic>
<privateStaticFinal>[a-zA-Z][\w]+</privateStaticFinal>
<protected>[a-z][\w]+</protected>
<protectedStatic>[a-z][\w]+</protectedStatic>
<protectedStaticFinal>[a-zA-Z][\w]+</protectedStaticFinal>
<public>[a-z][\w]+</public>
<publicStatic>[a-z][\w]+</publicStatic>
<publicStaticFinal>[a-zA-Z][\w]+</publicStaticFinal>
</fields>
<interfaces>[A-Z][a-zA-Z0-9]+</interfaces>
<labels>\w+</labels>
<methods>
<default>[a-z][\w]+</default>
<defaultStatic>[a-z][\w]+</defaultStatic>
<defaultStaticFinal>[a-z][\w]+</defaultStaticFinal>
<private>[a-z][\w]+</private>
<privateStatic>[a-z][\w]+</privateStatic>
<privateStaticFinal>[a-z][\w]+</privateStaticFinal>
<protected>[a-z][\w]+</protected>
<protectedStatic>[a-z][\w]+</protectedStatic>
<protectedStaticFinal>[a-z][\w]+</protectedStaticFinal>
<public>[a-z][\w]+</public>
<publicStatic>[a-z][\w]+</publicStatic>
<publicStaticFinal>[a-z][\w]+</publicStaticFinal>
</methods>
<packages>[a-z]+(?:\.[a-z]+)*</packages>
<parameters>
<default>[a-z][\w]+</default>
<final>[a-z][\w]+</final>
</parameters>
<variables>[a-z][\w]*</variables>
</naming>
<tips>
<adhereToNamingConvention>false</adhereToNamingConvention>
<alwaysOverrideHashCode>false</alwaysOverrideHashCode>
<avoidThreadGroups>false</avoidThreadGroups>
<declareCollectionComment>false</declareCollectionComment>
<dontIgnoreExceptions>false</dontIgnoreExceptions>
<dontSubstituteObjectEquals>false</dontSubstituteObjectEquals>
<neverDeclareException>false</neverDeclareException>
<neverDeclareThrowable>false</neverDeclareThrowable>
<neverInvokeWaitOutsideLoop>false</neverInvokeWaitOutsideLoop>
<neverReturnZeroArrays>false</neverReturnZeroArrays>
<neverUseEmptyFinally>false</neverUseEmptyFinally>
<obeyContractEquals>false</obeyContractEquals>
<overrideToString>false</overrideToString>
<referToObjectsByInterface>false</referToObjectsByInterface>
<replaceStructureWithClass>false</replaceStructureWithClass>
<stringLiterallI18n>false</stringLiterallI18n>
<useInterfaceOnlyForTypes>false</useInterfaceOnlyForTypes>
<wrongCollectionComment>false</wrongCollectionComment>
</tips>
</inspector>
<internal>
<version>6</version>
</internal>
<messages>
<priority>
<general>30000</general>
<parser>30000</parser>
<parserJavadoc>30000</parserJavadoc>
<printer>30000</printer>
<printerJavadoc>30000</printerJavadoc>
<transform>30000</transform>
</priority>
<showErrorStackTrace>true</showErrorStackTrace>
</messages>
<misc>
<threadCount>2</threadCount>
</misc>
<printer>
<alignment>
<methodCallChain>true</methodCallChain>
<parameterMethodDeclaration>false</parameterMethodDeclaration>
<ternaryOperator>true</ternaryOperator>
<variableAssignment>false</variableAssignment>
<variableIdentifier>false</variableIdentifier>
</alignment>
<backup>
<directory>bak</directory>
<level>0</level>
</backup>
<blanklines>
<after>
<block>1</block>
<braceLeft>0</braceLeft>
<class>1</class>
<declaration>0</declaration>
<footer>1</footer>
<header>0</header>
<interface>1</interface>
<lastImport>1</lastImport>
<method>1</method>
<package>1</package>
</after>
<before>
<block>1</block>
<braceRight>0</braceRight>
<caseBlock>1</caseBlock>
<comment>
<javadoc>1</javadoc>
<multiline>1</multiline>
<singleline>1</singleline>
</comment>
<controlStatement>1</controlStatement>
<declaration>1</declaration>
<footer>0</footer>
<header>2</header>
</before>
<keepUpTo>1</keepUpTo>
</blanklines>
<braces>
<empty>
<cuddle>false</cuddle>
<insertStatement>false</insertStatement>
</empty>
<insert>
<dowhile>true</dowhile>
<for>true</for>
<ifelse>true</ifelse>
<while>true</while>
</insert>
<remove>
<block>true</block>
<dowhile>false</dowhile>
<for>false</for>
<ifelse>false</ifelse>
<while>false</while>
</remove>
<treatDifferent>
<methodClass>true</methodClass>
<methodClassIfWrapped>true</methodClassIfWrapped>
</treatDifferent>
</braces>
<chunks>
<blanklines>true</blanklines>
<comments>true</comments>
</chunks>
<comments>
<format>
<multiline>false</multiline>
</format>
<javadoc>
<check>
<innerclass>false</innerclass>
<tags>false</tags>
<throwsTags>true</throwsTags>
</check>
<fieldsShort>false</fieldsShort>
<generate>
<class>0</class>
<constructor>0</constructor>
<field>0</field>
<method>0</method>
</generate>
<parseComments>false</parseComments>
<tags>
<in-line />
<standard />
</tags>
<templates>
<class>/**| * DOCUMENT ME!| *| * @author $author$| * @version $Revision: 120 $| */</class>
<constructor>
<bottom> */</bottom>
<exception> * @throws $exceptionType$ DOCUMENT ME!</exception>
<param> * @param $paramType$ DOCUMENT ME!</param>
<top>/**| * Creates a new $objectType$ object.</top>
</constructor>
<interface>/**| * DOCUMENT ME!| *| * @author $author$| * @version $Revision: 120 $| */</interface>
<method>
<bottom> */</bottom>
<exception> * @throws $exceptionType$ DOCUMENT ME!</exception>
<param> * @param $paramType$ DOCUMENT ME!</param>
<return> * @return DOCUMENT ME!</return>
<top>/**| * DOCUMENT ME!</top>
</method>
</templates>
</javadoc>
<remove>
<javadoc>false</javadoc>
<multiline>false</multiline>
<singleline>false</singleline>
</remove>
<separator>
<fillCharacter>-</fillCharacter>
<insert>false</insert>
<insertRecursive>false</insertRecursive>
<text>
<class>Inner Classes</class>
<constructor>Constructors</constructor>
<field>Instance fields</field>
<initializer>Instance initializers</initializer>
<interface>Inner Interfaces</interface>
<method>Methods</method>
<static>Static fields/initializers</static>
</text>
</separator>
</comments>
<environment />
<footer>
<keys />
<smartMode>0</smartMode>
<use>false</use>
</footer>
<header>
<keys>Tha Apache Software License</keys>
<smartMode>5</smartMode>
<text>/*| * Copyright 2001-2004 The Apache Software Foundation.| *| * Licensed under the Apache License, Version 2.0 (the "License");| * you may not use this file except in compliance with the License.| * You may obtain a copy of the License at| *| * http://www.apache.org/licenses/LICENSE-2.0| *| * Unless required by applicable law or agreed to in writing, software| * distributed under the License is distributed on an "AS IS" BASIS,| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.| * See the License for the specific language governing permissions and| * limitations under the License.| */</text>
<use>false</use>
</header>
<history>
<policy>disabled</policy>
</history>
<imports>
<grouping>
<defaultDepth>3</defaultDepth>
<packages>*:0|gnu:2|java:1|javax:1</packages>
</grouping>
<policy>disabled</policy>
<sort>true</sort>
</imports>
<indentation>
<caseFromSwitch>true</caseFromSwitch>
<continuation>
<block>true</block>
<operator>false</operator>
</continuation>
<firstColumnComments>false</firstColumnComments>
<label>false</label>
<policy>
<deep>true</deep>
</policy>
<sizes>
<braceCuddled>1</braceCuddled>
<braceLeft>0</braceLeft>
<braceRight>0</braceRight>
<braceRightAfter>1</braceRightAfter>
<continuation>4</continuation>
<deep>55</deep>
<extends>-1</extends>
<general>4</general>
<implements>-1</implements>
<leading>0</leading>
<tabs>8</tabs>
<throws>-1</throws>
<trailingComment>1</trailingComment>
</sizes>
<tabs>
<enable>false</enable>
<onlyLeading>false</onlyLeading>
</tabs>
</indentation>
<misc>
<arrayBracketsAfterIdent>false</arrayBracketsAfterIdent>
<forceFormatting>false</forceFormatting>
<insertExpressionParentheses>true</insertExpressionParentheses>
<insertLoggingConditional>false</insertLoggingConditional>
<insertTrailingNewline>true</insertTrailingNewline>
<insertUID>false</insertUID>
</misc>
<sorting>
<declaration>
<class>false</class>
<constructor>false</constructor>
<enable>false</enable>
<interface>false</interface>
<method>false</method>
<order>static|field|initializer|constructor|method|interface|class</order>
<variable>false</variable>
</declaration>
<modifier>
<enable>false</enable>
<order>public|protected|private|abstract|static|final|synchronized|transient|volatile|native|strictfp</order>
</modifier>
</sorting>
<whitespace>
<after>
<comma>true</comma>
<semicolon>true</semicolon>
<typeCast>true</typeCast>
</after>
<before>
<braces>true</braces>
<brackets>false</brackets>
<bracketsTypes>false</bracketsTypes>
<caseColon>false</caseColon>
<operator>
<not>true</not>
</operator>
<parentheses>
<methodCall>false</methodCall>
<methodDeclaration>false</methodDeclaration>
<statement>true</statement>
</parentheses>
</before>
<padding>
<braces>true</braces>
<brackets>false</brackets>
<operator>
<assignment>true</assignment>
<bitwise>true</bitwise>
<logical>true</logical>
<mathematical>true</mathematical>
<relational>true</relational>
<shift>true</shift>
</operator>
<parenthesis>true</parenthesis>
<typeCast>false</typeCast>
</padding>
</whitespace>
<wrapping>
<always>
<after>
<arrayElement>0</arrayElement>
<braceRight>false</braceRight>
<extendsTypes>false</extendsTypes>
<implementsTypes>false</implementsTypes>
<label>true</label>
<methodCallChained>false</methodCallChained>
<ternaryOperator>
<first>false</first>
<second>false</second>
</ternaryOperator>
<throwsTypes>false</throwsTypes>
</after>
<before>
<braceLeft>true</braceLeft>
<extends>true</extends>
<implements>true</implements>
<throws>true</throws>
</before>
<parameter>
<methodCall>false</methodCall>
<methodCallNested>true</methodCallNested>
<methodDeclaration>false</methodDeclaration>
</parameter>
</always>
<general>
<beforeOperator>false</beforeOperator>
<enable>true</enable>
<lineLength>120</lineLength>
</general>
<ondemand>
<after>
<assignment>true</assignment>
<leftParenthesis>false</leftParenthesis>
<parameter>true</parameter>
<types>
<extends>true</extends>
<implements>true</implements>
<throws>true</throws>
</types>
</after>
<before>
<rightParenthesis>false</rightParenthesis>
</before>
<groupingParentheses>true</groupingParentheses>
</ondemand>
</wrapping>
</printer>
</jalopy>
@@ -0,0 +1,42 @@
package com.shape;
import java.io.File;
import java.lang.Math;
public class Circle
extends Point
{
public final float PI = 3.1415926535897932385f;
public float Circumference;
public int Diameter;
private int Radius;
public float getCircumference( )
{
Circumference = 2 * ( Radius * PI );
return Circumference;
}
public int getDiameter( )
{
Diameter = Radius * 2;
return Diameter;
}
public void setRadius( int intRadius )
{
this.Radius = intRadius;
}
public int getRadius( )
{
return this.Radius;
}
public static void main( String[] args )
{
System.out.println( "Main Program for Junit Sample triggered!" );
}
}
@@ -0,0 +1,27 @@
package com.shape;
public class Point
{
private int x;
private int y;
public void setX( int xValue )
{
x = xValue;
}
public int getX( )
{
return this.x;
}
public void setY( int yValue )
{
y = yValue;
}
public int getY( )
{
return this.y;
}
}
@@ -0,0 +1,57 @@
package com.shape;
public class Rectangle
{
private float Hypotenuse;
private int Area;
private int Height;
private int Perimeter;
private int Width;
public int getArea( )
{
this.Area = this.Width * this.Height;
return this.Area;
}
public void setHeight( int height )
{
Height = height;
}
public int getHeight( )
{
return this.Height;
}
public float getHypotenuse( )
{
this.Hypotenuse = (float) Math.sqrt( Math.pow( this.Height, 2.0 ) + Math.pow( this.Width, 2.0 ) );
return this.Hypotenuse;
}
public int getPerimeter( )
{
this.Perimeter = ( 2 * this.Width ) + ( 2 * this.Height );
return this.Perimeter;
}
public void setWidth( int width )
{
Width = width;
}
public int getWidth( )
{
return this.Width;
}
public void setWidthHeight( int width, int height )
{
setWidth( width );
setHeight( height );
}
}
+2
View File
@@ -24,6 +24,8 @@
</properties>
<body>
<release version="1.4.1-SNAPSHOT" date="In SVN">
<action dev="ltheussl" type="update" issue="MPJALOPY-10">Rewrite the plugin so it doesn't use the jalopy ant task anymore.</action>
<action dev="ltheussl" type="add">New properties maven.jalopy.inspect, maven.jalopy.backup and maven.jalopy.force. Removed properties maven.jalopy.logLevel and maven.jalopy.nbThread.</action>
<action dev="aheritier" type="update" issue="MAVEN-1759">Upgrade to log4j 1.2.13.</action>
<action dev="aheritier" type="fix" issue="MPJALOPY-9">Jalopy classes aren't found.</action>
<action dev="aheritier" type="update" issue="MAVEN-1753">Replace the deprecated xmlParserAPIs by xml-apis 1.3.03.</action>
+24 -17
View File
@@ -57,23 +57,6 @@
"FILE" or "NONE" can be used. Defaults to "none".
</td>
</tr>
<tr>
<td>maven.jalopy.logLevel</td>
<td>Yes</td>
<td>
Specifies the logging level for message output. Either one of
"ERROR", "WARN", "INFO" or "DEBUG" can be used.
Defaults to "info".
</td>
</tr>
<tr>
<td>maven.jalopy.nbThread</td>
<td>Yes</td>
<td>
Specifies the number of processing threads to use. Integer between 1 - 8.
Defaults to "2".
</td>
</tr>
<tr>
<td>maven.jalopy.failOnError</td>
<td>Yes</td>
@@ -81,6 +64,30 @@
Indicates whether a run should be held if errors occured. Defaults to "true".
</td>
</tr>
<tr>
<td>maven.jalopy.inspect</td>
<td>Yes</td>
<td>
Indicates whether source files should be inspected during a format.
Defaults to "false".
</td>
</tr>
<tr>
<td>maven.jalopy.backup</td>
<td>Yes</td>
<td>
Indicates whether to keep backup copies of formatted files.
Defaults to "false".
</td>
</tr>
<tr>
<td>maven.jalopy.force</td>
<td>Yes</td>
<td>
Indicates whether to force the formatting.
Defaults to "false".
</td>
</tr>
<tr>
<td>maven.jalopy.filesetInclude</td>
<td>Yes</td>