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
2fec9c47
Commit
2fec9c47
authored
May 30, 2014
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.0.x'
parents
ef7390d3
8f7c96e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
5 deletions
+68
-5
AetherGrapeEngine.java
...gframework/boot/cli/compiler/grape/AetherGrapeEngine.java
+18
-4
AetherGrapeEngineTests.java
...ework/boot/cli/compiler/grape/AetherGrapeEngineTests.java
+50
-1
No files found.
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java
View file @
2fec9c47
...
...
@@ -49,7 +49,7 @@ import org.springframework.boot.cli.compiler.DependencyResolutionContext;
* A {@link GrapeEngine} implementation that uses <a
* href="http://eclipse.org/aether">Aether</a>, the dependency resolution system used by
* Maven.
*
*
* @author Andy Wilkinson
* @author Phillip Webb
*/
...
...
@@ -171,13 +171,27 @@ public class AetherGrapeEngine implements GrapeEngine {
String
group
=
(
String
)
dependencyMap
.
get
(
"group"
);
String
module
=
(
String
)
dependencyMap
.
get
(
"module"
);
String
version
=
(
String
)
dependencyMap
.
get
(
"version"
);
String
classifier
=
(
String
)
dependencyMap
.
get
(
"classifier"
);
String
type
=
determineType
(
dependencyMap
);
return
new
DefaultArtifact
(
group
,
module
,
classifier
,
type
,
version
);
}
private
String
determineType
(
Map
<?,
?>
dependencyMap
)
{
String
type
=
(
String
)
dependencyMap
.
get
(
"type"
);
String
ext
=
(
String
)
dependencyMap
.
get
(
"ext"
);
if
(
type
==
null
)
{
type
=
"jar"
;
type
=
ext
;
if
(
type
==
null
)
{
type
=
"jar"
;
}
}
return
new
DefaultArtifact
(
group
,
module
,
type
,
version
);
else
if
(
ext
!=
null
&&
!
type
.
equals
(
ext
))
{
throw
new
IllegalArgumentException
(
"If both type and ext are specified they must have the same value"
);
}
return
type
;
}
private
boolean
isTransitive
(
Map
<?,
?>
dependencyMap
)
{
...
...
spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java
View file @
2fec9c47
...
...
@@ -19,7 +19,9 @@ package org.springframework.boot.cli.compiler.grape;
import
groovy.lang.GroovyClassLoader
;
import
java.net.URI
;
import
java.net.URL
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -34,7 +36,7 @@ import static org.junit.Assert.assertTrue;
/**
* Tests for {@link AetherGrapeEngine}.
*
*
* @author Andy Wilkinson
*/
public
class
AetherGrapeEngineTests
{
...
...
@@ -113,6 +115,53 @@ public class AetherGrapeEngineTests {
assertEquals
(
1
,
this
.
groovyClassLoader
.
getURLs
().
length
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
differingTypeAndExt
()
{
Map
<
String
,
Object
>
dependency
=
createDependency
(
"org.grails"
,
"grails-dependencies"
,
"2.4.0"
);
dependency
.
put
(
"type"
,
"foo"
);
dependency
.
put
(
"ext"
,
"bar"
);
this
.
grapeEngine
.
grab
(
Collections
.
emptyMap
(),
dependency
);
}
@Test
public
void
pomDependencyResolutionViaType
()
{
Map
<
String
,
Object
>
args
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
dependency
=
createDependency
(
"org.springframework"
,
"spring-framework-bom"
,
"4.0.5.RELEASE"
);
dependency
.
put
(
"type"
,
"pom"
);
this
.
grapeEngine
.
grab
(
args
,
dependency
);
URL
[]
urls
=
this
.
groovyClassLoader
.
getURLs
();
assertEquals
(
1
,
urls
.
length
);
assertTrue
(
urls
[
0
].
toExternalForm
().
endsWith
(
".pom"
));
}
@Test
public
void
pomDependencyResolutionViaExt
()
{
Map
<
String
,
Object
>
args
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
dependency
=
createDependency
(
"org.springframework"
,
"spring-framework-bom"
,
"4.0.5.RELEASE"
);
dependency
.
put
(
"ext"
,
"pom"
);
this
.
grapeEngine
.
grab
(
args
,
dependency
);
URL
[]
urls
=
this
.
groovyClassLoader
.
getURLs
();
assertEquals
(
1
,
urls
.
length
);
assertTrue
(
urls
[
0
].
toExternalForm
().
endsWith
(
".pom"
));
}
@Test
public
void
resolutionWithClassifier
()
{
Map
<
String
,
Object
>
args
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
dependency
=
createDependency
(
"org.springframework"
,
"spring-jdbc"
,
"3.2.4.RELEASE"
,
false
);
dependency
.
put
(
"classifier"
,
"sources"
);
this
.
grapeEngine
.
grab
(
args
,
dependency
);
URL
[]
urls
=
this
.
groovyClassLoader
.
getURLs
();
assertEquals
(
1
,
urls
.
length
);
assertTrue
(
urls
[
0
].
toExternalForm
().
endsWith
(
"-sources.jar"
));
}
private
Map
<
String
,
Object
>
createDependency
(
String
group
,
String
module
,
String
version
)
{
Map
<
String
,
Object
>
dependency
=
new
HashMap
<
String
,
Object
>();
...
...
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