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
0e7757de
Commit
0e7757de
authored
Aug 21, 2014
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.1.x'
parents
595c8112
69c61d0e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
129 additions
and
4 deletions
+129
-4
MultiProjectRepackagingTests.java
...ngframework/boot/gradle/MultiProjectRepackagingTests.java
+61
-0
ProjectCreator.java
.../java/org/springframework/boot/gradle/ProjectCreator.java
+10
-2
RepackagingTests.java
...ava/org/springframework/boot/gradle/RepackagingTests.java
+0
-1
build.gradle
...s/src/test/resources/multi-project-repackage/build.gradle
+40
-0
settings.gradle
...rc/test/resources/multi-project-repackage/settings.gradle
+3
-0
ProjectLibraries.java
...ringframework/boot/gradle/repackage/ProjectLibraries.java
+15
-1
No files found.
spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/MultiProjectRepackagingTests.java
0 → 100644
View file @
0e7757de
/*
* 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
.
gradle
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.jar.JarFile
;
import
org.gradle.tooling.ProjectConnection
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.springframework.boot.dependency.tools.ManagedDependencies
;
import
org.springframework.util.FileCopyUtils
;
import
static
org
.
hamcrest
.
Matchers
.
notNullValue
;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
* Integration tests for Gradle repackaging with a multi-project build.
*
* @author Andy Wilkinson
*/
public
class
MultiProjectRepackagingTests
{
private
static
final
String
BOOT_VERSION
=
ManagedDependencies
.
get
()
.
find
(
"spring-boot"
).
getVersion
();
private
static
ProjectConnection
project
;
@BeforeClass
public
static
void
createProject
()
throws
IOException
{
project
=
new
ProjectCreator
().
createProject
(
"multi-project-repackage"
);
}
@Test
public
void
repackageWithTransitiveFileDependency
()
throws
Exception
{
FileCopyUtils
.
copy
(
new
File
(
"src/test/resources/foo.jar"
),
new
File
(
"target/multi-project-repackage/foo.jar"
));
project
.
newBuild
().
forTasks
(
"clean"
,
"build"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
).
run
();
File
buildLibs
=
new
File
(
"target/multi-project-repackage/main/build/libs"
);
JarFile
jarFile
=
new
JarFile
(
new
File
(
buildLibs
,
"main.jar"
));
assertThat
(
jarFile
.
getEntry
(
"lib/commons-logging-1.1.3.jar"
),
notNullValue
());
assertThat
(
jarFile
.
getEntry
(
"lib/foo.jar"
),
notNullValue
());
jarFile
.
close
();
}
}
spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/ProjectCreator.java
View file @
0e7757de
...
...
@@ -23,6 +23,7 @@ import org.gradle.tooling.GradleConnector;
import
org.gradle.tooling.ProjectConnection
;
import
org.gradle.tooling.internal.consumer.DefaultGradleConnector
;
import
org.springframework.util.FileCopyUtils
;
import
org.springframework.util.FileSystemUtils
;
/**
* @author Andy Wilkinson
...
...
@@ -34,8 +35,15 @@ public class ProjectCreator {
projectDirectory
.
mkdirs
();
File
gradleScript
=
new
File
(
projectDirectory
,
"build.gradle"
);
if
(
new
File
(
"src/test/resources"
,
name
).
isDirectory
())
{
FileSystemUtils
.
copyRecursively
(
new
File
(
"src/test/resources"
,
name
),
projectDirectory
);
}
else
{
FileCopyUtils
.
copy
(
new
File
(
"src/test/resources/"
+
name
+
".gradle"
),
gradleScript
);
}
GradleConnector
gradleConnector
=
GradleConnector
.
newConnector
();
((
DefaultGradleConnector
)
gradleConnector
).
embedded
(
true
);
...
...
spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/RepackagingTests.java
View file @
0e7757de
...
...
@@ -132,5 +132,4 @@ public class RepackagingTests {
assertThat
(
jarFile
.
getEntry
(
"lib/foo.jar"
),
notNullValue
());
jarFile
.
close
();
}
}
spring-boot-integration-tests/src/test/resources/multi-project-repackage/build.gradle
0 → 100644
View file @
0e7757de
buildscript
{
repositories
{
mavenLocal
()
}
dependencies
{
classpath
"org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
}
}
project
(
'main'
)
{
apply
plugin:
'spring-boot'
apply
plugin:
'java'
repositories
{
mavenLocal
()
mavenCentral
()
}
dependencies
{
compile
project
(
':common'
)
}
springBoot
{
mainClass
=
'foo.bar.Baz'
}
}
project
(
'common'
)
{
apply
plugin:
'java'
repositories
{
mavenLocal
()
mavenCentral
()
}
dependencies
{
compile
"commons-logging:commons-logging:1.1.3"
compile
files
{
"lib/foo.jar"
}
}
}
\ No newline at end of file
spring-boot-integration-tests/src/test/resources/multi-project-repackage/settings.gradle
0 → 100644
View file @
0e7757de
include
'main'
include
'common'
\ No newline at end of file
spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/ProjectLibraries.java
View file @
0e7757de
...
...
@@ -27,6 +27,7 @@ import org.gradle.api.artifacts.Configuration;
import
org.gradle.api.artifacts.Dependency
;
import
org.gradle.api.artifacts.FileCollectionDependency
;
import
org.gradle.api.artifacts.ModuleVersionIdentifier
;
import
org.gradle.api.artifacts.ProjectDependency
;
import
org.gradle.api.artifacts.ResolvedArtifact
;
import
org.springframework.boot.gradle.SpringBootPluginExtension
;
import
org.springframework.boot.loader.tools.Libraries
;
...
...
@@ -109,6 +110,14 @@ class ProjectLibraries implements Libraries {
.
getResolvedArtifacts
())
{
libraries
.
add
(
new
ResolvedArtifactLibrary
(
artifact
,
scope
));
}
libraries
.
addAll
(
getLibrariesForFileDependencies
(
configuration
,
scope
));
return
libraries
;
}
private
Set
<
Library
>
getLibrariesForFileDependencies
(
Configuration
configuration
,
LibraryScope
scope
)
{
Set
<
Library
>
libraries
=
new
LinkedHashSet
<
Library
>();
for
(
Dependency
dependency
:
configuration
.
getIncoming
().
getDependencies
())
{
if
(
dependency
instanceof
FileCollectionDependency
)
{
FileCollectionDependency
fileDependency
=
(
FileCollectionDependency
)
dependency
;
...
...
@@ -116,6 +125,11 @@ class ProjectLibraries implements Libraries {
libraries
.
add
(
new
Library
(
file
,
scope
));
}
}
else
if
(
dependency
instanceof
ProjectDependency
)
{
ProjectDependency
projectDependency
=
(
ProjectDependency
)
dependency
;
libraries
.
addAll
(
getLibrariesForFileDependencies
(
projectDependency
.
getProjectConfiguration
(),
scope
));
}
}
return
libraries
;
}
...
...
@@ -161,7 +175,7 @@ class ProjectLibraries implements Libraries {
@Override
public
boolean
isUnpackRequired
()
{
if
(
ProjectLibraries
.
this
.
extension
.
getRequiresUnpack
()
!=
null
)
{
ModuleVersionIdentifier
id
=
artifact
.
getModuleVersion
().
getId
();
ModuleVersionIdentifier
id
=
this
.
artifact
.
getModuleVersion
().
getId
();
return
ProjectLibraries
.
this
.
extension
.
getRequiresUnpack
().
contains
(
id
.
getGroup
()
+
":"
+
id
.
getName
());
}
...
...
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