From cd5124005b9531d1c2da1621d32cf4afdaef2d06 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 25 Jan 2017 16:37:18 +0000 Subject: [PATCH] Deprecate support for module layout Closes gh-8008 --- .../boot/gradle/SpringBootPluginExtension.java | 4 ++-- .../boot/gradle/repackage/RepackageTask.java | 14 +++++++++++--- .../springframework/boot/loader/tools/Layouts.java | 4 +++- .../boot/loader/tools/LayoutsTests.java | 3 ++- .../springframework/boot/maven/RepackageMojo.java | 9 +++++++-- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/SpringBootPluginExtension.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/SpringBootPluginExtension.java index 3ddd57c5a5..764a90a358 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/SpringBootPluginExtension.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/SpringBootPluginExtension.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -304,7 +304,7 @@ public class SpringBootPluginExtension { DIR(new Layouts.Expanded()), - MODULE(new Layouts.Module()), + @SuppressWarnings("deprecation") MODULE(new Layouts.Module()), NONE(new Layouts.None()); diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/RepackageTask.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/RepackageTask.java index 4e78f2478b..9503925d12 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/RepackageTask.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/RepackageTask.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -33,6 +33,8 @@ import org.gradle.api.tasks.bundling.Jar; import org.springframework.boot.gradle.SpringBootPluginExtension; import org.springframework.boot.loader.tools.DefaultLaunchScript; import org.springframework.boot.loader.tools.LaunchScript; +import org.springframework.boot.loader.tools.Layout; +import org.springframework.boot.loader.tools.Layouts; import org.springframework.boot.loader.tools.Repackager; import org.springframework.boot.loader.tools.Repackager.MainClassTimeoutWarningListener; import org.springframework.util.FileCopyUtils; @@ -207,6 +209,7 @@ public class RepackageTask extends DefaultTask { return task.equals(withJarTask) || task.getName().equals(withJarTask); } + @SuppressWarnings("deprecation") private void repackage(File file) { File outputFile = RepackageTask.this.outputFile; if (outputFile != null && !file.equals(outputFile)) { @@ -218,8 +221,13 @@ public class RepackageTask extends DefaultTask { repackager.addMainClassTimeoutWarningListener( new LoggingMainClassTimeoutWarningListener()); setMainClass(repackager); - if (this.extension.convertLayout() != null) { - repackager.setLayout(this.extension.convertLayout()); + Layout layout = this.extension.convertLayout(); + if (layout != null) { + if (layout instanceof Layouts.Module) { + getLogger().warn("Module layout is deprecated. Please use a custom" + + " LayoutFactory instead."); + } + repackager.setLayout(layout); } repackager.setBackupSource(this.extension.isBackupSource()); try { diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java index 3cebdc7a05..9901d3c958 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layouts.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -158,7 +158,9 @@ public final class Layouts { /** * Module layout (designed to be used as a "plug-in"). + * @deprecated since 1.5 in favour of a custom {@link LayoutFactory} */ + @Deprecated public static class Module implements Layout { private static final Set LIB_DESTINATION_SCOPES = new HashSet( diff --git a/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/LayoutsTests.java b/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/LayoutsTests.java index e7a32fed12..1dfd2467f0 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/LayoutsTests.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/LayoutsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -87,6 +87,7 @@ public class LayoutsTests { } @Test + @SuppressWarnings("deprecation") public void moduleLayout() throws Exception { Layout layout = new Layouts.Module(); assertThat(layout.getLibraryDestination("lib.jar", LibraryScope.COMPILE)) diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java index 7569d02142..5228e210a7 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -236,6 +236,10 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { repackager.setMainClass(this.mainClass); if (this.layout != null) { getLog().info("Layout: " + this.layout); + if (this.layout == LayoutType.MODULE) { + getLog().warn("Module layout is deprecated. Please use a custom" + + " LayoutFactory instead."); + } repackager.setLayout(this.layout.layout()); } return repackager; @@ -344,8 +348,9 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { /** * Module Layout. + * @deprecated since 1.5 in favour of a custom {@link LayoutFactory} */ - MODULE(new Layouts.Module()), + @Deprecated MODULE(new Layouts.Module()), /** * No Layout.