Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions aardvark/src/gw/vark/Aardvark.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import gw.util.Pair;
import gw.util.StreamUtil;
import gw.vark.annotations.Depends;
import gw.vark.shell.InteractiveShell;
import gw.vark.typeloader.AntlibTypeLoader;
import org.apache.tools.ant.*;
import org.apache.tools.ant.launch.AntMain;
Expand Down Expand Up @@ -138,6 +139,11 @@ public int startAardvark(String[] args) {
return EXITCODE_GOSU_VERIFY_FAILED;
}

if (options.isInteractive()) {
InteractiveShell.start(this, varkFile, gosuProgram);
return 0;
}

int exitCode = 1;
try {
try {
Expand Down Expand Up @@ -302,8 +308,11 @@ public static String getHelp( String varkFilePath, IType gosuProgram )
for (int i = 0, parametersLength = parameters.length; i < parametersLength; i++) {
IParameterInfo param = parameters[i];
description += "\n -" + param.getName();
if (methodInfo instanceof IOptionalParamCapable && ((IOptionalParamCapable) methodInfo).getDefaultValues()[i] != null) {
description += " (optional, default " + ((IOptionalParamCapable) methodInfo).getDefaultValues()[i] + ")";
if (methodInfo instanceof IOptionalParamCapable) {
IExpression defaultValue = ((IOptionalParamCapable) methodInfo).getDefaultValueExpressions()[i];
if (defaultValue != null) {
description += " (optional, default " + defaultValue.evaluate() + ")";
}
}
if (GosuStringUtil.isNotBlank(param.getDescription())) {
description += ": " + param.getDescription();
Expand Down
14 changes: 7 additions & 7 deletions aardvark/src/gw/vark/ProjectHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package gw.vark;

import gw.lang.parser.IExpression;
import gw.lang.reflect.*;
import gw.lang.reflect.gs.IGosuProgram;
import gw.lang.reflect.gs.IProgramInstance;
import gw.lang.reflect.java.IJavaType;
import gw.lang.reflect.java.JavaTypes;
import gw.vark.annotations.Depends;
import org.apache.tools.ant.BuildException;
Expand Down Expand Up @@ -181,11 +181,11 @@ private Object determineStringParamVal(String paramName, Map<String, String> use
return userValue;
}
else {
Object defaultValue = ((IOptionalParamCapable)_methodInfo).getDefaultValues()[i];
IExpression defaultValue = ((IOptionalParamCapable)_methodInfo).getDefaultValueExpressions()[i];
if (defaultValue == null) {
throw new IllegalArgumentException("requires parameter \"" + paramName + "\"");
}
return defaultValue;
return defaultValue.evaluate();
}
}

Expand All @@ -207,11 +207,11 @@ else if (userValue.equals("false")) {
}
}
else {
Object defaultValue = ((IOptionalParamCapable)_methodInfo).getDefaultValues()[i];
IExpression defaultValue = ((IOptionalParamCapable)_methodInfo).getDefaultValueExpressions()[i];
if (defaultValue == null) {
return false;
}
return defaultValue;
return defaultValue.evaluate();
}
}

Expand All @@ -229,11 +229,11 @@ private Object determineIntParamVal(String paramName, Map<String, String> userPa
}
}
else {
Object defaultValue = ((IOptionalParamCapable)_methodInfo).getDefaultValues()[i];
IExpression defaultValue = ((IOptionalParamCapable)_methodInfo).getDefaultValueExpressions()[i];
if (defaultValue == null) {
throw new IllegalArgumentException("requires parameter \"" + paramName + "\"");
}
return defaultValue;
return defaultValue.evaluate();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions aardvark/src/gw/vark/shell/InteractiveShell.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import gw.vark.Aardvark;
import gw.vark.AardvarkOptions;
import gw.vark.GosuProgramWrapper;
import jline.ConsoleReader;
import jline.Terminal;
import gw.internal.ext.jline.ConsoleReader;
import gw.internal.ext.jline.Terminal;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;

Expand Down
9 changes: 4 additions & 5 deletions aardvark/src/gw/vark/typeloader/AntlibTypeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

package gw.vark.typeloader;

import gw.lang.GosuShop;
import gw.lang.function.IFunction1;
import gw.lang.parser.ISymbol;
import gw.lang.reflect.*;
import gw.lang.reflect.java.CustomTypeInfoBase;
import gw.lang.reflect.java.IJavaType;
import gw.lang.reflect.java.JavaTypes;
import gw.util.GosuExceptionUtil;
import gw.util.Pair;
Expand Down Expand Up @@ -239,7 +238,7 @@ ParameterInfoBuilder createParameterInfoBuilder() {
return new ParameterInfoBuilder()
.withName(getParamName())
.withType(makeParamType(_type))
.withDefValue(ISymbol.NULL_DEFAULT_VALUE);
.withDefValue(GosuShop.getNullExpressionInstance());
}

@Override
Expand Down Expand Up @@ -286,7 +285,7 @@ ParameterInfoBuilder createParameterInfoBuilder() {
return new ParameterInfoBuilder()
.withName(getParamName())
.withType(makeListType(_type))
.withDefValue(ISymbol.NULL_DEFAULT_VALUE);
.withDefValue(GosuShop.getNullExpressionInstance());
}

@Override
Expand Down Expand Up @@ -323,7 +322,7 @@ ParameterInfoBuilder createParameterInfoBuilder() {
return new ParameterInfoBuilder()
.withName(getParamName())
.withType(makeListOfBlocksType(_type))
.withDefValue(ISymbol.NULL_DEFAULT_VALUE);
.withDefValue(GosuShop.getNullExpressionInstance());
}

@Override
Expand Down
13 changes: 4 additions & 9 deletions aardvark/src/gw/vark/typeloader/AntlibTypeLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import gw.lang.reflect.TypeSystem;
import gw.lang.reflect.module.IModule;
import gw.util.GosuExceptionUtil;
import gw.util.Pair;
import gw.util.StreamUtil;
import gw.util.concurrent.LockingLazyVar;
import gw.vark.Aardvark;
Expand All @@ -32,15 +33,9 @@ public class AntlibTypeLoader extends TypeLoaderBase implements ITypeLoader{
protected HashMap<String, IType> init()
{
HashMap<String, String> antlibs = new HashMap<String, String>();
for (IDirectory sourceEntry : TypeSystem.getCurrentModule().getResourceAccess().getSourceEntries()) {
IDirectory antlibsDir = sourceEntry.dir(GW_VARK_TASKS_PATH);
if (antlibsDir.exists()) {
for (IFile file : antlibsDir.listFiles()) {
if ("antlib".equals(file.getExtension())) {
antlibs.put(file.getBaseName(), readFile(file).trim());
}
}
}
for (Pair<String, IFile> pair : TypeSystem.getExecutionEnvironment().getCurrentModule().getFileRepository().findAllFilesByExtension("antlib")) {
IFile file = pair.getSecond();
antlibs.put(file.getBaseName(), readFile(file).trim());
}
antlibs.put(ANT_ANTLIB_SYMBOL, ANT_ANTLIB_RESOURCE);

Expand Down
26 changes: 25 additions & 1 deletion aardvark/test/gw/vark/TestprojectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void targetWithBooleanArgDefaultValueFalseUserValueTrue() {
}

@Test
public void targetWithBooleanArgDefaultValueFalseNoUserValue() {
public void targetWithBooleanArgDefaultValueFalseUserValueImpliedTrue() {
InMemoryLogger results = vark("target-with-boolean-arg-default-false", "-foo");
assertThat(results).matches(
StringMatchAssertion.exact(""),
Expand All @@ -226,6 +226,30 @@ public void targetWithBooleanArgDefaultValueFalseNoUserValue() {
StringMatchAssertion.regex("Total time: \\d+ seconds?"));
}

@Test
public void targetWithBooleanArgDefaultValueFalseNoUserValue() {
InMemoryLogger results = vark("target-with-boolean-arg-default-false");
assertThat(results).matches(
StringMatchAssertion.exact(""),
StringMatchAssertion.exact("target-with-boolean-arg-default-false:"),
StringMatchAssertion.exact(" [echo] foo: false (boolean)"),
StringMatchAssertion.exact(""),
StringMatchAssertion.exact("BUILD SUCCESSFUL"),
StringMatchAssertion.regex("Total time: \\d+ seconds?"));
}

@Test
public void targetWithBooleanArgDefaultValueTrueNoUserValue() {
InMemoryLogger results = vark("target-with-boolean-arg-default-true");
assertThat(results).matches(
StringMatchAssertion.exact(""),
StringMatchAssertion.exact("target-with-boolean-arg-default-true:"),
StringMatchAssertion.exact(" [echo] foo: true (boolean)"),
StringMatchAssertion.exact(""),
StringMatchAssertion.exact("BUILD SUCCESSFUL"),
StringMatchAssertion.regex("Total time: \\d+ seconds?"));
}

@Test
public void targetWithBooleanArgDefaultValueTrueUserValueFalse() {
InMemoryLogger results = vark("target-with-boolean-arg-default-true", "-foo", "false");
Expand Down
4 changes: 2 additions & 2 deletions build.vark
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function resolve() {
}
}

log("Renaming jvmtiaccess_linux.so to jvmtiaccess.so")
Ant.move(:file = file("lib/run/jvmtiaccess_linux.so"), :tofile = file("lib/run/jvmtiaccess.so"))
//log("Renaming jvmtiaccess_linux.so to jvmtiaccess.so")
//Ant.move(:file = file("lib/run/jvmtiaccess_linux.so"), :tofile = file("lib/run/jvmtiaccess.so"))
}

@Depends("resolve")
Expand Down
1 change: 0 additions & 1 deletion ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<exclude module="servlet-api"/>
</dependency>
<dependency org="gw" name="gosu-xml" rev="0.9-SNAPSHOT" conf="run->default"/>
<dependency org="gw" name="gosu-core-api" rev="0.9-SNAPSHOT" conf="sources->sources"/>

<dependency org="junit" name="junit" rev="4.8.2" conf="test->default; sources->sources"/>
<dependency org="org.easytesting" name="fest-assert" rev="1.4" conf="test->default; sources->sources"/>
Expand Down
3 changes: 2 additions & 1 deletion ivysettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<resolvers>
<chain name="default">
<ibiblio name="nexus" m2compatible="true" root="http://nexus:8081/nexus/content/groups/public"/>
<ibiblio name="central" m2compatible="true" root="http://repo1.maven.org/maven2"/>
<ibiblio name="gosu" m2compatible="true" root="http://gosu-lang.org/m2"/>
<url name="antsource">
<artifact pattern="http://archive.apache.org/dist/ant/source/[artifact]-[revision]-src.zip"/>
</url>
Expand Down