Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
796816e8
Commit
796816e8
authored
Jan 16, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove CleanCommand
Fixes gh-230
parent
c8a1d883
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1 addition
and
288 deletions
+1
-288
DefaultCommandFactory.java
...ringframework/boot/cli/command/DefaultCommandFactory.java
+1
-3
CleanCommand.java
...g/springframework/boot/cli/command/grab/CleanCommand.java
+0
-198
CliTester.java
...src/test/java/org/springframework/boot/cli/CliTester.java
+0
-2
GrapesCleaner.java
...test/java/org/springframework/boot/cli/GrapesCleaner.java
+0
-71
SampleIntegrationTests.java
.../org/springframework/boot/cli/SampleIntegrationTests.java
+0
-6
TestCommandIntegrationTests.java
...springframework/boot/cli/TestCommandIntegrationTests.java
+0
-8
No files found.
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/DefaultCommandFactory.java
View file @
796816e8
...
...
@@ -21,7 +21,6 @@ import java.util.Collection;
import
java.util.List
;
import
org.springframework.boot.cli.command.core.VersionCommand
;
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
;
...
...
@@ -34,8 +33,7 @@ import org.springframework.boot.cli.command.test.TestCommand;
public
class
DefaultCommandFactory
implements
CommandFactory
{
private
static
final
List
<
Command
>
DEFAULT_COMMANDS
=
Arrays
.<
Command
>
asList
(
new
VersionCommand
(),
new
RunCommand
(),
new
TestCommand
(),
new
GrabCommand
(),
new
CleanCommand
());
new
VersionCommand
(),
new
RunCommand
(),
new
TestCommand
(),
new
GrabCommand
());
@Override
public
Collection
<
Command
>
getCommands
()
{
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/grab/CleanCommand.java
deleted
100644 → 0
View file @
c8a1d883
/*
* 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
.
command
.
grab
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
import
joptsimple.OptionSet
;
import
joptsimple.OptionSpec
;
import
org.springframework.boot.cli.Log
;
import
org.springframework.boot.cli.command.Command
;
import
org.springframework.boot.cli.command.OptionHandler
;
import
org.springframework.boot.cli.command.OptionParsingCommand
;
/**
* {@link Command} to 'clean' up grapes, removing cached dependencies and forcing a
* download on the next attempt to resolve.
*
* @author Dave Syer
*/
public
class
CleanCommand
extends
OptionParsingCommand
{
public
CleanCommand
()
{
super
(
"clean"
,
"Clean up groovy grapes "
+
"(useful if snapshots are needed and you need an update)"
,
new
CleanOptionHandler
());
}
@Override
public
String
getUsageHelp
()
{
return
"[options] <dependencies>"
;
}
private
static
class
CleanOptionHandler
extends
OptionHandler
{
private
OptionSpec
<
Void
>
allOption
;
private
OptionSpec
<
Void
>
ivyOption
;
private
OptionSpec
<
Void
>
mvnOption
;
@Override
protected
void
options
()
{
this
.
allOption
=
option
(
"all"
,
"Clean all files (not just snapshots)"
);
this
.
ivyOption
=
option
(
"ivy"
,
"Clean just ivy (grapes) cache. "
+
"Default is on unless --maven is used."
);
this
.
mvnOption
=
option
(
"maven"
,
"Clean just maven cache. Default is off."
);
}
@Override
protected
void
run
(
OptionSet
options
)
throws
Exception
{
if
(!
options
.
has
(
this
.
ivyOption
))
{
clean
(
options
,
getGrapesHome
(),
Layout
.
IVY
);
}
if
(
options
.
has
(
this
.
mvnOption
))
{
if
(
options
.
has
(
this
.
ivyOption
))
{
clean
(
options
,
getGrapesHome
(),
Layout
.
IVY
);
}
clean
(
options
,
getMavenHome
(),
Layout
.
MAVEN
);
}
}
private
void
clean
(
OptionSet
options
,
File
root
,
Layout
layout
)
{
if
(
root
==
null
||
!
root
.
exists
())
{
return
;
}
ArrayList
<
Object
>
specs
=
new
ArrayList
<
Object
>(
options
.
nonOptionArguments
());
if
(!
specs
.
contains
(
"org.springframework.boot"
)
&&
layout
==
Layout
.
IVY
)
{
specs
.
add
(
0
,
"org.springframework.boot"
);
}
for
(
Object
spec
:
specs
)
{
if
(
spec
instanceof
String
)
{
clean
(
options
,
root
,
layout
,
(
String
)
spec
);
}
}
}
private
void
clean
(
OptionSet
options
,
File
root
,
Layout
layout
,
String
spec
)
{
String
group
=
spec
;
String
module
=
null
;
if
(
spec
.
contains
(
":"
))
{
group
=
spec
.
substring
(
0
,
spec
.
indexOf
(
':'
));
module
=
spec
.
substring
(
spec
.
indexOf
(
':'
)
+
1
);
}
File
file
=
getModulePath
(
root
,
group
,
module
,
layout
);
if
(!
file
.
exists
())
{
return
;
}
if
(
options
.
has
(
this
.
allOption
)
||
group
.
equals
(
"org.springframework.boot"
))
{
delete
(
file
);
return
;
}
for
(
Object
obj
:
recursiveList
(
file
))
{
File
candidate
=
(
File
)
obj
;
if
(
candidate
.
getName
().
contains
(
"SNAPSHOT"
))
{
delete
(
candidate
);
}
}
}
private
void
delete
(
File
file
)
{
Log
.
info
(
"Deleting: "
+
file
);
recursiveDelete
(
file
);
}
private
File
getModulePath
(
File
root
,
String
group
,
String
module
,
Layout
layout
)
{
File
parent
=
root
;
if
(
layout
==
Layout
.
IVY
)
{
parent
=
new
File
(
parent
,
group
);
}
else
{
for
(
String
path
:
group
.
split
(
"\\."
))
{
parent
=
new
File
(
parent
,
path
);
}
}
if
(
module
==
null
)
{
return
parent
;
}
return
new
File
(
parent
,
module
);
}
private
File
getGrapesHome
()
{
String
dir
=
System
.
getenv
(
"GROOVY_HOME"
);
String
userdir
=
System
.
getProperty
(
"user.home"
);
File
home
;
if
(
dir
==
null
||
!
new
File
(
dir
).
exists
())
{
dir
=
userdir
;
home
=
new
File
(
dir
,
".groovy"
);
}
else
{
home
=
new
File
(
dir
);
}
if
(
dir
==
null
||
!
new
File
(
dir
).
exists
())
{
return
null
;
}
return
new
File
(
home
,
"grapes"
);
}
private
File
getMavenHome
()
{
String
dir
=
System
.
getProperty
(
"user.home"
);
if
(
dir
==
null
||
!
new
File
(
dir
).
exists
())
{
return
null
;
}
File
home
=
new
File
(
dir
);
return
new
File
(
new
File
(
home
,
".m2"
),
"repository"
);
}
private
static
enum
Layout
{
IVY
,
MAVEN
;
}
private
void
recursiveDelete
(
File
file
)
{
if
(
file
.
exists
())
{
if
(
file
.
isDirectory
())
{
for
(
File
inDir
:
file
.
listFiles
())
{
recursiveDelete
(
inDir
);
}
}
if
(!
file
.
delete
())
{
throw
new
IllegalStateException
(
"Failed to delete "
+
file
);
}
}
}
private
List
<
File
>
recursiveList
(
File
file
)
{
List
<
File
>
files
=
new
ArrayList
<
File
>();
if
(
file
.
isDirectory
())
{
for
(
File
inDir
:
file
.
listFiles
())
{
files
.
addAll
(
recursiveList
(
inDir
));
}
}
files
.
add
(
file
);
return
files
;
}
}
}
spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTester.java
View file @
796816e8
...
...
@@ -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
();
}
...
...
spring-boot-cli/src/test/java/org/springframework/boot/cli/GrapesCleaner.java
deleted
100644 → 0
View file @
c8a1d883
/*
* 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"
);
}
}
spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java
View file @
796816e8
...
...
@@ -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"
);
...
...
spring-boot-cli/src/test/java/org/springframework/boot/cli/TestCommandIntegrationTests.java
View file @
796816e8
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment