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
d137bcd8
Commit
d137bcd8
authored
Feb 06, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish gradle repackage task formatting
parent
f8ab5a1f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
49 deletions
+63
-49
Repackage.java
...roovy/org/springframework/boot/gradle/task/Repackage.java
+63
-49
No files found.
spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/task/Repackage.java
View file @
d137bcd8
...
...
@@ -59,9 +59,9 @@ public class Repackage extends DefaultTask {
@TaskAction
public
void
repackage
()
{
Project
project
=
getProject
();
final
SpringBootPluginExtension
extension
=
project
.
getExtensions
().
getByType
(
SpringBootPluginExtension
extension
=
project
.
getExtensions
().
getByType
(
SpringBootPluginExtension
.
class
);
final
ProjectLibraries
libraries
=
new
ProjectLibraries
(
project
);
ProjectLibraries
libraries
=
new
ProjectLibraries
(
project
);
if
(
extension
.
getProvidedConfiguration
()
!=
null
)
{
libraries
.
setProvidedConfigurationName
(
extension
.
getProvidedConfiguration
());
}
...
...
@@ -71,59 +71,73 @@ public class Repackage extends DefaultTask {
else
if
(
extension
.
getCustomConfiguration
()
!=
null
)
{
libraries
.
setCustomConfigurationName
(
extension
.
getCustomConfiguration
());
}
project
.
getTasks
().
withType
(
Jar
.
class
,
new
RepackageAction
(
extension
,
libraries
));
}
project
.
getTasks
().
withType
(
Jar
.
class
,
new
Action
<
Jar
>()
{
private
class
RepackageAction
implements
Action
<
Jar
>
{
@Override
public
void
execute
(
Jar
archive
)
{
// if withJarTask is set, compare tasks
// and bail out if we didn't match
if
(
Repackage
.
this
.
withJarTask
!=
null
&&
!
archive
.
equals
(
Repackage
.
this
.
withJarTask
))
{
return
;
}
private
final
SpringBootPluginExtension
extension
;
private
final
ProjectLibraries
libraries
;
public
RepackageAction
(
SpringBootPluginExtension
extension
,
ProjectLibraries
libraries
)
{
this
.
extension
=
extension
;
this
.
libraries
=
libraries
;
}
if
(
""
.
equals
(
archive
.
getClassifier
()))
{
File
file
=
archive
.
getArchivePath
();
if
(
file
.
exists
())
{
Repackager
repackager
=
new
Repackager
(
file
)
{
@Override
protected
String
findMainMethod
(
java
.
util
.
jar
.
JarFile
source
)
throws
IOException
{
long
startTime
=
System
.
currentTimeMillis
();
try
{
return
super
.
findMainMethod
(
source
);
}
finally
{
long
duration
=
System
.
currentTimeMillis
()
-
startTime
;
if
(
duration
>
FIND_WARNING_TIMEOUT
)
{
getLogger
()
.
warn
(
"Searching for the "
+
"main-class is taking some time, "
+
"consider using setting 'springBoot.mainClass'"
);
}
}
};
};
repackager
.
setMainClass
(
Repackage
.
this
.
mainClass
!=
null
?
Repackage
.
this
.
mainClass
:
extension
.
getMainClass
());
if
(
extension
.
convertLayout
()
!=
null
)
{
repackager
.
setLayout
(
extension
.
convertLayout
());
}
repackager
.
setBackupSource
(
extension
.
isBackupSource
());
try
{
repackager
.
repackage
(
libraries
);
}
catch
(
IOException
ex
)
{
throw
new
IllegalStateException
(
ex
.
getMessage
(),
ex
);
}
@Override
public
void
execute
(
Jar
archive
)
{
// if withJarTask is set, compare tasks and bail out if we didn't match
if
(
Repackage
.
this
.
withJarTask
!=
null
&&
!
archive
.
equals
(
Repackage
.
this
.
withJarTask
))
{
return
;
}
if
(
""
.
equals
(
archive
.
getClassifier
()))
{
File
file
=
archive
.
getArchivePath
();
if
(
file
.
exists
())
{
Repackager
repackager
=
new
LoggingRepackager
(
file
);
repackager
.
setMainClass
(
this
.
extension
.
getMainClass
());
if
(
Repackage
.
this
.
mainClass
!=
null
)
{
repackager
.
setMainClass
(
Repackage
.
this
.
mainClass
);
}
if
(
this
.
extension
.
convertLayout
()
!=
null
)
{
repackager
.
setLayout
(
this
.
extension
.
convertLayout
());
}
repackager
.
setBackupSource
(
this
.
extension
.
isBackupSource
());
try
{
repackager
.
repackage
(
this
.
libraries
);
}
catch
(
IOException
ex
)
{
throw
new
IllegalStateException
(
ex
.
getMessage
(),
ex
);
}
}
}
}
);
}
}
private
class
LoggingRepackager
extends
Repackager
{
public
LoggingRepackager
(
File
source
)
{
super
(
source
);
}
@Override
protected
String
findMainMethod
(
java
.
util
.
jar
.
JarFile
source
)
throws
IOException
{
long
startTime
=
System
.
currentTimeMillis
();
try
{
return
super
.
findMainMethod
(
source
);
}
finally
{
long
duration
=
System
.
currentTimeMillis
()
-
startTime
;
if
(
duration
>
FIND_WARNING_TIMEOUT
)
{
getLogger
().
warn
(
"Searching for the main-class is taking "
+
"some time, consider using setting "
+
"'springBoot.mainClass'"
);
}
}
};
}
}
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