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
cee8c9f4
Commit
cee8c9f4
authored
Aug 19, 2014
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.1.x'
parents
39923838
5f9fddd4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
13 deletions
+113
-13
AetherGrapeEngine.java
...gframework/boot/cli/compiler/grape/AetherGrapeEngine.java
+30
-1
SettingsXmlRepositorySystemSessionAutoConfiguration.java
.../SettingsXmlRepositorySystemSessionAutoConfiguration.java
+1
-3
AetherGrapeEngineTests.java
...ework/boot/cli/compiler/grape/AetherGrapeEngineTests.java
+82
-9
No files found.
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java
View file @
cee8c9f4
...
...
@@ -263,12 +263,41 @@ public class AetherGrapeEngine implements GrapeEngine {
if
(
this
.
repositories
.
contains
(
repository
))
{
return
;
}
repository
=
getPossibleMirror
(
repository
);
repository
=
applyProxy
(
repository
);
repository
=
applyAuthentication
(
repository
);
this
.
repositories
.
add
(
0
,
repository
);
}
private
RemoteRepository
getPossibleMirror
(
RemoteRepository
remoteRepository
)
{
RemoteRepository
mirror
=
this
.
session
.
getMirrorSelector
().
getMirror
(
remoteRepository
);
if
(
mirror
!=
null
)
{
return
mirror
;
}
return
remoteRepository
;
}
private
RemoteRepository
applyProxy
(
RemoteRepository
repository
)
{
if
(
repository
.
getProxy
()
==
null
)
{
RemoteRepository
.
Builder
builder
=
new
RemoteRepository
.
Builder
(
repository
);
builder
.
setProxy
(
this
.
session
.
getProxySelector
().
getProxy
(
repository
));
repository
=
builder
.
build
();
}
this
.
repositories
.
add
(
0
,
repository
);
return
repository
;
}
private
RemoteRepository
applyAuthentication
(
RemoteRepository
repository
)
{
if
(
repository
.
getAuthentication
()
==
null
)
{
RemoteRepository
.
Builder
builder
=
new
RemoteRepository
.
Builder
(
repository
);
builder
.
setAuthentication
(
this
.
session
.
getAuthenticationSelector
()
.
getAuthentication
(
repository
));
repository
=
builder
.
build
();
}
return
repository
;
}
@Override
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/SettingsXmlRepositorySystemSessionAutoConfiguration.java
View file @
cee8c9f4
...
...
@@ -58,12 +58,10 @@ import org.springframework.boot.cli.util.Log;
public
class
SettingsXmlRepositorySystemSessionAutoConfiguration
implements
RepositorySystemSessionAutoConfiguration
{
private
static
final
String
DEFAULT_HOME_DIR
=
System
.
getProperty
(
"user.home"
);
private
final
String
homeDir
;
public
SettingsXmlRepositorySystemSessionAutoConfiguration
()
{
this
(
DEFAULT_HOME_DIR
);
this
(
System
.
getProperty
(
"user.home"
)
);
}
SettingsXmlRepositorySystemSessionAutoConfiguration
(
String
homeDir
)
{
...
...
spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngineTests.java
View file @
cee8c9f4
...
...
@@ -18,19 +18,23 @@ package org.springframework.boot.cli.compiler.grape;
import
groovy.lang.GroovyClassLoader
;
import
java.io.File
;
import
java.net.URI
;
import
java.net.URL
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.eclipse.aether.DefaultRepositorySystemSession
;
import
org.eclipse.aether.util.repository.JreProxySelector
;
import
org.eclipse.aether.repository.Authentication
;
import
org.eclipse.aether.repository.RemoteRepository
;
import
org.junit.Test
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
...
...
@@ -42,10 +46,14 @@ public class AetherGrapeEngineTests {
private
final
GroovyClassLoader
groovyClassLoader
=
new
GroovyClassLoader
();
private
final
AetherGrapeEngine
grapeEngine
=
AetherGrapeEngineFactory
.
create
(
this
.
groovyClassLoader
,
Arrays
.
asList
(
new
RepositoryConfiguration
(
"central"
,
URI
.
create
(
"http://repo1.maven.org/maven2"
),
false
)),
new
DependencyResolutionContext
());
private
final
AetherGrapeEngine
grapeEngine
=
createGrapeEngine
();
private
AetherGrapeEngine
createGrapeEngine
()
{
return
AetherGrapeEngineFactory
.
create
(
this
.
groovyClassLoader
,
Arrays
.
asList
(
new
RepositoryConfiguration
(
"central"
,
URI
.
create
(
"http://repo1.maven.org/maven2"
),
false
)),
new
DependencyResolutionContext
());
}
@Test
public
void
dependencyResolution
()
{
...
...
@@ -59,10 +67,53 @@ public class AetherGrapeEngineTests {
@Test
public
void
proxySelector
()
{
DefaultRepositorySystemSession
session
=
(
DefaultRepositorySystemSession
)
ReflectionTestUtils
.
getField
(
this
.
grapeEngine
,
"session"
);
assertTrue
((
session
.
getProxySelector
()
instanceof
CompositeProxySelector
)
||
(
session
.
getProxySelector
()
instanceof
JreProxySelector
));
doWithCustomUserHome
(
new
Runnable
()
{
@Override
public
void
run
()
{
AetherGrapeEngine
grapeEngine
=
createGrapeEngine
();
DefaultRepositorySystemSession
session
=
(
DefaultRepositorySystemSession
)
ReflectionTestUtils
.
getField
(
grapeEngine
,
"session"
);
assertTrue
(
session
.
getProxySelector
()
instanceof
CompositeProxySelector
);
}
});
}
@Test
public
void
repositoryMirrors
()
{
doWithCustomUserHome
(
new
Runnable
()
{
@SuppressWarnings
(
"unchecked"
)
@Override
public
void
run
()
{
AetherGrapeEngine
grapeEngine
=
createGrapeEngine
();
List
<
RemoteRepository
>
repositories
=
(
List
<
RemoteRepository
>)
ReflectionTestUtils
.
getField
(
grapeEngine
,
"repositories"
);
assertEquals
(
1
,
repositories
.
size
());
assertEquals
(
"central-mirror"
,
repositories
.
get
(
0
).
getId
());
}
});
}
@Test
public
void
repositoryAuthentication
()
{
doWithCustomUserHome
(
new
Runnable
()
{
@SuppressWarnings
(
"unchecked"
)
@Override
public
void
run
()
{
AetherGrapeEngine
grapeEngine
=
createGrapeEngine
();
List
<
RemoteRepository
>
repositories
=
(
List
<
RemoteRepository
>)
ReflectionTestUtils
.
getField
(
grapeEngine
,
"repositories"
);
assertEquals
(
1
,
repositories
.
size
());
Authentication
authentication
=
repositories
.
get
(
0
).
getAuthentication
();
assertNotNull
(
authentication
);
}
});
}
@SuppressWarnings
(
"unchecked"
)
...
...
@@ -190,4 +241,26 @@ public class AetherGrapeEngineTests {
exclusion
.
put
(
"module"
,
module
);
return
exclusion
;
}
private
void
doWithCustomUserHome
(
Runnable
action
)
{
doWithSystemProperty
(
"user.home"
,
new
File
(
"src/test/resources"
).
getAbsolutePath
(),
action
);
}
private
void
doWithSystemProperty
(
String
key
,
String
value
,
Runnable
action
)
{
String
previousValue
=
setOrClearSystemProperty
(
key
,
value
);
try
{
action
.
run
();
}
finally
{
setOrClearSystemProperty
(
key
,
previousValue
);
}
}
private
String
setOrClearSystemProperty
(
String
key
,
String
value
)
{
if
(
value
!=
null
)
{
return
System
.
setProperty
(
key
,
value
);
}
return
System
.
clearProperty
(
key
);
}
}
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