Remove CleanCommand

Fixes gh-230
This commit is contained in:
Dave Syer
2014-01-16 17:29:52 +00:00
parent c8a1d8830c
commit 796816e8c3
6 changed files with 1 additions and 288 deletions

View File

@@ -35,7 +35,6 @@ import org.junit.runners.model.Statement;
import org.springframework.boot.OutputCapture;
import org.springframework.boot.cli.command.AbstractCommand;
import org.springframework.boot.cli.command.OptionParsingCommand;
import org.springframework.boot.cli.command.grab.CleanCommand;
import org.springframework.boot.cli.command.grab.GrabCommand;
import org.springframework.boot.cli.command.run.RunCommand;
import org.springframework.boot.cli.command.test.TestCommand;
@@ -173,7 +172,6 @@ public class CliTester implements TestRule {
public void evaluate() throws Throwable {
System.setProperty("disableSpringSnapshotRepos", "false");
try {
new CleanCommand().run("org.springframework");
try {
this.base.evaluate();
}

View File

@@ -1,71 +0,0 @@
/*
* Copyright 2012-2014 the original author or authors.
*
* 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.
*/
package org.springframework.boot.cli;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.springframework.boot.cli.command.grab.CleanCommand;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* @author Dave Syer
*/
public class GrapesCleaner {
private static final String VERSION;
static {
try {
File pom = new File("pom.xml");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(pom);
Element parent = (Element) document.getDocumentElement()
.getElementsByTagName("parent").item(0);
VERSION = parent.getElementsByTagName("version").item(0).getFirstChild()
.getTextContent();
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
}
public static void cleanIfNecessary() throws Exception {
File installedJar = new File(getMavenRepository(), String.format(
"org/springframework/boot/spring-boot/%s/spring-boot-%s.jar", VERSION,
VERSION));
File grapesJar = new File(getGrapesCache(), String.format(
"org.springframework.boot/spring-boot/jars/spring-boot-%s.jar", VERSION));
if (!VERSION.contains("SNAPSHOT") || installedJar.exists() && grapesJar.exists()
&& installedJar.lastModified() <= grapesJar.lastModified()) {
return;
}
new CleanCommand().run();
}
private static File getMavenRepository() {
return new File(System.getProperty("user.home"), ".m2/repository");
}
private static File getGrapesCache() {
return new File(System.getProperty("user.home"), ".groovy/grapes");
}
}

View File

@@ -20,7 +20,6 @@ import java.io.File;
import java.net.URI;
import org.codehaus.plexus.util.FileUtils;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -41,11 +40,6 @@ public class SampleIntegrationTests {
@Rule
public CliTester cli = new CliTester("samples/");
@BeforeClass
public static void cleanGrapes() throws Exception {
GrapesCleaner.cleanIfNecessary();
}
@Test
public void appSample() throws Exception {
String output = this.cli.run("app.groovy");

View File

@@ -18,11 +18,9 @@ package org.springframework.boot.cli;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.boot.cli.command.grab.CleanCommand;
import org.springframework.boot.cli.command.test.TestCommand;
import static org.hamcrest.Matchers.containsString;
@@ -42,15 +40,9 @@ public class TestCommandIntegrationTests {
@Rule
public CliTester cli = new CliTester("test-samples/");
@BeforeClass
public static void cleanGrapes() throws Exception {
GrapesCleaner.cleanIfNecessary();
}
@Before
public void setup() throws Exception {
System.setProperty("disableSpringSnapshotRepos", "false");
new CleanCommand().run("org.springframework");
}
@After