Polish "Include LICENCE and NOTICE files in shipped jars"

See gh-20058
pull/20230/head
Andy Wilkinson 5 years ago
parent e34cf8955c
commit 8128f3090a

@ -23,7 +23,6 @@ import java.io.InputStreamReader;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.Year;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
@ -77,7 +76,8 @@ import org.springframework.util.FileCopyUtils;
* <li>{@link JavaCompile}, {@link Javadoc}, and {@link FormatTask} tasks are configured * <li>{@link JavaCompile}, {@link Javadoc}, and {@link FormatTask} tasks are configured
* to use UTF-8 encoding * to use UTF-8 encoding
* <li>{@link JavaCompile} tasks are configured to use {@code -parameters} * <li>{@link JavaCompile} tasks are configured to use {@code -parameters}
* <li>{@link Jar} tasks are configured to have the following manifest entries: * <li>{@link Jar} tasks are configured to produce jars with LICENSE.txt and NOTICE.txt
* files and the following manifest entries:
* <ul> * <ul>
* <li>{@code Automatic-Module-Name} * <li>{@code Automatic-Module-Name}
* <li>{@code Build-Jdk-Spec} * <li>{@code Build-Jdk-Spec}
@ -109,6 +109,7 @@ import org.springframework.util.FileCopyUtils;
* {@link AsciidoctorConventions} are applied. * {@link AsciidoctorConventions} are applied.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Christoph Dreis
*/ */
public class ConventionsPlugin implements Plugin<Project> { public class ConventionsPlugin implements Plugin<Project> {
@ -163,8 +164,7 @@ public class ConventionsPlugin implements Plugin<Project> {
try { try {
InputStream notice = getClass().getClassLoader().getResourceAsStream("NOTICE.txt"); InputStream notice = getClass().getClassLoader().getResourceAsStream("NOTICE.txt");
String noticeContent = FileCopyUtils.copyToString(new InputStreamReader(notice, StandardCharsets.UTF_8)) String noticeContent = FileCopyUtils.copyToString(new InputStreamReader(notice, StandardCharsets.UTF_8))
.replace("${version}", project.getVersion().toString()) .replace("${version}", project.getVersion().toString());
.replace("${currentYear}", Integer.toString(Year.now().getValue()));
TextResourceFactory resourceFactory = project.getResources().getText(); TextResourceFactory resourceFactory = project.getResources().getText();
File file = createLegalFile(resourceFactory.fromString(noticeContent).asFile(), "NOTICE.txt"); File file = createLegalFile(resourceFactory.fromString(noticeContent).asFile(), "NOTICE.txt");
metaInf.from(file); metaInf.from(file);

@ -1,5 +1,5 @@
Spring Boot ${version} Spring Boot ${version}
Copyright (c) 2012-${currentYear} Pivotal, Inc. Copyright (c) 2012-2020 Pivotal, Inc.
This product is licensed to you under the Apache License, Version 2.0 This product is licensed to you under the Apache License, Version 2.0
(the "License"). You may not use this product except in compliance with (the "License"). You may not use this product except in compliance with

@ -44,8 +44,6 @@ class ConventionsPluginTests {
private File buildFile; private File buildFile;
private File licenseFile;
@BeforeEach @BeforeEach
void setup(@TempDir File projectDir) throws IOException { void setup(@TempDir File projectDir) throws IOException {
this.projectDir = projectDir; this.projectDir = projectDir;

Loading…
Cancel
Save