You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by rd...@apache.org on 2011/08/07 19:43:35 UTC
svn commit: r1154736 - in /incubator/rat/whisker/trunk/legacy/src:
main/java/org/apache/rat/whisker/legacy/app/
main/java/org/apache/rat/whisker/legacy/cli/
test/java/org/apache/rat/whisker/legacy/cli/
Author: rdonkin
Date: Sun Aug 7 17:43:34 2011
New Revision: 1154736
URL: http://svn.apache.org/viewvc?rev=1154736&view=rev
Log:
Command line setting for audit source.
Modified:
incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/app/Whisker.java
incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/app/WhiskerVelocity.java
incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/cli/CommandLineOption.java
incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/cli/Main.java
incubator/rat/whisker/trunk/legacy/src/test/java/org/apache/rat/whisker/legacy/cli/TestCommandParsing.java
Modified: incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/app/Whisker.java
URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/app/Whisker.java?rev=1154736&r1=1154735&r2=1154736&view=diff
==============================================================================
--- incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/app/Whisker.java (original)
+++ incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/app/Whisker.java Sun Aug 7 17:43:34 2011
@@ -30,24 +30,22 @@ import org.apache.rat.whisker.legacy.sca
*/
public class Whisker {
-
-
private Act act = Act.TEMPLATE;
- private String base = "app";
+ private String source = "app";
private String licenseDescriptor = "org/apache/rat/whisker/samples/james/james.xml";
/**
* @return the base
*/
- public String getBase() {
- return base;
+ public String getSource() {
+ return source;
}
/**
- * @param base the base to set
+ * @param source the base to set
*/
- public Whisker setBase(String base) {
- this.base = base;
+ public Whisker setSource(String source) {
+ this.source = source;
return this;
}
@@ -152,13 +150,13 @@ public class Whisker {
* @return
* @throws IOException
*/
- protected Collection<Directory> fileSystem() throws IOException {
- return new FromFileSystem().withBase(getBase());
+ protected Collection<Directory> directories() throws IOException {
+ return new FromFileSystem().withBase(getSource());
}
@Override
public String toString() {
- return "Whisker [act=" + act + ", base=" + base
+ return "Whisker [act=" + act + ", base=" + source
+ ", licenseDescriptor=" + licenseDescriptor + "]";
}
}
Modified: incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/app/WhiskerVelocity.java
URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/app/WhiskerVelocity.java?rev=1154736&r1=1154735&r2=1154736&view=diff
==============================================================================
--- incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/app/WhiskerVelocity.java (original)
+++ incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/app/WhiskerVelocity.java Sun Aug 7 17:43:34 2011
@@ -35,7 +35,7 @@ public class WhiskerVelocity extends Whi
*/
@Override
protected void doValidate() throws Exception {
- new Engine().check(getLicenseDescriptor(), fileSystem());
+ new Engine().check(getLicenseDescriptor(), directories());
}
/**
@@ -43,7 +43,7 @@ public class WhiskerVelocity extends Whi
*/
@Override
protected void doReport() throws Exception {
- new Engine().write(fileSystem());
+ new Engine().write(directories());
}
/**
@@ -51,6 +51,6 @@ public class WhiskerVelocity extends Whi
*/
@Override
protected void doTemplateGeneration() throws Exception {
- new Engine().generateTemplate(fileSystem());
+ new Engine().generateTemplate(directories());
}
}
Modified: incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/cli/CommandLineOption.java
URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/cli/CommandLineOption.java?rev=1154736&r1=1154735&r2=1154736&view=diff
==============================================================================
--- incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/cli/CommandLineOption.java (original)
+++ incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/cli/CommandLineOption.java Sun Aug 7 17:43:34 2011
@@ -30,6 +30,7 @@ import org.apache.commons.cli.Options;
public enum CommandLineOption {
LICENSE_DESCRIPTION("license-descriptor", 'l', "use given license descriptor", true, "file", false),
+ SOURCE("source", 's', "application source", false, "dir", false),
ACT_TO_GENERATE("generate", 'g', "generate license and notice", false, null, true),
ACT_TO_AUDIT("audit", 'a', "report audit details", false, null, true);
Modified: incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/cli/Main.java
URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/cli/Main.java?rev=1154736&r1=1154735&r2=1154736&view=diff
==============================================================================
--- incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/cli/Main.java (original)
+++ incubator/rat/whisker/trunk/legacy/src/main/java/org/apache/rat/whisker/legacy/cli/Main.java Sun Aug 7 17:43:34 2011
@@ -81,13 +81,14 @@ public class Main {
* @return not null
*/
private Whisker configure(final CommandLine commandLine) {
+ whisker.setSource(CommandLineOption.SOURCE.getOptionValue(commandLine));
whisker.setLicenseDescriptor(CommandLineOption.LICENSE_DESCRIPTION.getOptionValue(commandLine));
if (CommandLineOption.ACT_TO_AUDIT.isSetOn(commandLine)) {
whisker.setAct(Act.AUDIT);
} else if (CommandLineOption.ACT_TO_GENERATE.isSetOn(commandLine)) {
whisker.setAct(Act.GENERATE);
}
- return whisker.setBase("war");
+ return whisker;
}
public int run(final String[] args) throws Exception {
Modified: incubator/rat/whisker/trunk/legacy/src/test/java/org/apache/rat/whisker/legacy/cli/TestCommandParsing.java
URL: http://svn.apache.org/viewvc/incubator/rat/whisker/trunk/legacy/src/test/java/org/apache/rat/whisker/legacy/cli/TestCommandParsing.java?rev=1154736&r1=1154735&r2=1154736&view=diff
==============================================================================
--- incubator/rat/whisker/trunk/legacy/src/test/java/org/apache/rat/whisker/legacy/cli/TestCommandParsing.java (original)
+++ incubator/rat/whisker/trunk/legacy/src/test/java/org/apache/rat/whisker/legacy/cli/TestCommandParsing.java Sun Aug 7 17:43:34 2011
@@ -79,6 +79,28 @@ public class TestCommandParsing extends
args(longOpt(CommandLineOption.LICENSE_DESCRIPTION.getLongName()), "PATH", shortOpt(option.getShortName()))).getAct());
}
+ public void testSetSourceByCli() throws Exception {
+ checkSourceWithPath("/some/path");
+ checkSourceWithPath("/");
+ checkSourceWithPath("relative");
+ }
+
+ /**
+ * @param aPath
+ */
+ private void checkSourceWithPath(String aPath) throws Exception {
+ checkSource(aPath, shortOpt(CommandLineOption.SOURCE.getShortName()));
+ checkSource(aPath, longOpt(CommandLineOption.SOURCE.getLongName()));
+ }
+
+
+ private void checkSource(String aPath, String arg) throws ParseException {
+ assertEquals("Source arg should set property on Whisker", aPath,
+ subject.configure(args(arg, aPath,
+ longOpt(CommandLineOption.ACT_TO_AUDIT.getLongName()),
+ shortOpt(CommandLineOption.LICENSE_DESCRIPTION.getShortName()), "Whatever/bin")).getSource());
+ }
+
public void testSetLicenseDescriptorShortByCLI() throws Exception {
exerciseShortLicenseDescriptionWithPath("/some/path");