public Task nantTask() { if (isNantTask()) { return task; } return new NantTask(); }
public BuildTask toBuildTask(CRBuildTask crBuildTask) { BuildTask buildTask; switch (crBuildTask.getType()) { case rake: buildTask = new RakeTask(); break; case ant: buildTask = new AntTask(); break; case nant: buildTask = new NantTask(); break; default: throw new RuntimeException( String.format("unknown type of build task '%s'", crBuildTask.getType())); } setCommonBuildTaskMembers(buildTask, crBuildTask); setCommonTaskMembers(buildTask, crBuildTask); return buildTask; }
@Test public void commandShouldShowFullNantPath() { NantTask task = new NantTask(); String path = "c:/nant/bin"; task.setNantPath(path); assertThat(task.command(), is(new File(path, "nant").getPath())); }
public static NantTask fromJSON(JsonReader jsonReader) { NantTask nantTask = new NantTask(); if (jsonReader == null) { return nantTask; } BaseTaskRepresenter.fromJSON(jsonReader, nantTask); jsonReader.readStringIfPresent("working_directory", nantTask::setWorkingDirectory); jsonReader.readStringIfPresent("build_file", nantTask::setBuildFile); jsonReader.readStringIfPresent("target", nantTask::setTarget); jsonReader.readStringIfPresent("nant_path", nantTask::setNantPath); return nantTask; } }
public static NantTask fromJSON(JsonReader jsonReader) { NantTask nantTask = new NantTask(); if (jsonReader == null) { return nantTask; } BaseTaskRepresenter.fromJSON(jsonReader, nantTask); jsonReader.readStringIfPresent("working_directory", nantTask::setWorkingDirectory); jsonReader.readStringIfPresent("build_file", nantTask::setBuildFile); jsonReader.readStringIfPresent("target", nantTask::setTarget); jsonReader.readStringIfPresent("nant_path", nantTask::setNantPath); return nantTask; } }
@Test public void shouldSetPrimitiveAttributesForNantTask() { Map hashMap = new HashMap(); hashMap.put(OnCancelConfig.ON_CANCEL_OPTIONS, "nant"); Map valueMap = new HashMap(); valueMap.put(BuildTask.BUILD_FILE, "default.build"); valueMap.put(BuildTask.TARGET, "compile"); valueMap.put(BuildTask.WORKING_DIRECTORY, "pwd"); valueMap.put(NantTask.NANT_PATH, "/usr/bin/nant"); hashMap.put(OnCancelConfig.NANT_ON_CANCEL, valueMap); hashMap.put(OnCancelConfig.EXEC_ON_CANCEL, new HashMap()); hashMap.put(OnCancelConfig.ANT_ON_CANCEL, new HashMap()); hashMap.put(OnCancelConfig.RAKE_ON_CANCEL, new HashMap()); when(taskFactory.taskInstanceFor(new NantTask().getTaskType())).thenReturn(new NantTask()); OnCancelConfig cancelConfig = OnCancelConfig.create(hashMap, taskFactory); NantTask expectedNantTask = new NantTask(); expectedNantTask.setBuildFile("default.build"); expectedNantTask.setTarget("compile"); expectedNantTask.setWorkingDirectory("pwd"); expectedNantTask.setNantPath("/usr/bin/nant"); assertThat(cancelConfig.getTask(), is(expectedNantTask)); }
@Test public void shouldNotUpdateAllItsAttributesWhenNotPassedInAsAttributes() throws Exception { NantTask nant = new NantTask(); nant.setConfigAttributes(m(BuildTask.BUILD_FILE, null, NantTask.NANT_PATH, null)); assertThat(nant.getBuildFile(), is(nullValue())); assertThat(nant.getNantPath(), is(nullValue())); }
@Test public void shouldGiveArgumentsIncludingBuildfileAndTarget() { NantTask task = new NantTask(); task.setBuildFile("build/build.xml"); task.setTarget("compile"); assertThat(task.arguments(), is("-buildfile:\"build/build.xml\" compile")); } }
@Test public void describeTest() throws Exception { NantTask task = new NantTask(); task.setBuildFile("default.build"); task.setTarget("test"); task.setWorkingDirectory("lib"); task.setNantPath("tmp"); assertThat(task.describe(), is("tmp" + File.separator + "nant -buildfile:\"default.build\" test (workingDirectory: lib)")); }
@Test public void shouldUpdateAllItsAttributes() throws Exception { NantTask nant = new NantTask(); nant.setConfigAttributes(m(BuildTask.BUILD_FILE, "foo/build.xml", NantTask.NANT_PATH, "/usr/bin/nant")); assertThat(nant.getBuildFile(), is("foo/build.xml")); assertThat(nant.getNantPath(), is("/usr/bin/nant")); nant.setConfigAttributes(m()); assertThat(nant.getBuildFile(), is("foo/build.xml")); assertThat(nant.getNantPath(), is("/usr/bin/nant")); nant.setConfigAttributes(null); assertThat(nant.getBuildFile(), is("foo/build.xml")); assertThat(nant.getNantPath(), is("/usr/bin/nant")); }
@Test public void shouldReturnPropertiesPopulatedWithNantpath() { NantTask nantTask = new NantTask(); assertThat(nantTask.getPropertiesForDisplay().isEmpty(), is(true)); nantTask.setBuildFile("some-file.xml"); nantTask.setTarget("bulls_eye"); nantTask.setWorkingDirectory("some/dir"); nantTask.setNantPath("foo/bar/baz"); assertThat(nantTask.getPropertiesForDisplay(), hasItems(new TaskProperty("Nant Path", "foo/bar/baz", "nant_path"), new TaskProperty("Build File", "some-file.xml", "build_file"), new TaskProperty("Target", "bulls_eye", "target"), new TaskProperty("Working Directory", "some/dir", "working_directory"))); assertThat(nantTask.getPropertiesForDisplay().size(), is(4)); }
@Test public void shouldRegisterViewEnginesForAllTasks() { assertReturnsAppropriateViewModelForInbuiltTasks(registry, new AntTask(), "ant"); assertReturnsAppropriateViewModelForInbuiltTasks(registry, new ExecTask(), "exec"); assertReturnsAppropriateViewModelForInbuiltTasks(registry, new FetchTask(), "fetch"); assertReturnsAppropriateViewModelForInbuiltTasks(registry, new RakeTask(), "rake"); assertReturnsAppropriateViewModelForInbuiltTasks(registry, new NantTask(), "nant"); }