Revert Layout changes
This reverts commits: -pull/6613/head974ec92ad6
. -537e0c12c2
. -500a3df6e9
.
parent
9fc8d61107
commit
97fee46682
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2015 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.loader.tools;
|
||||
|
||||
/**
|
||||
* Strategy for creating instances of {@link Layout}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface LayoutFactory {
|
||||
|
||||
Layout getLayout();
|
||||
|
||||
String getName();
|
||||
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2015 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.loader.tools;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
|
||||
/**
|
||||
* Archive layout types.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public enum LayoutType {
|
||||
|
||||
/**
|
||||
* Jar Layout.
|
||||
*/
|
||||
JAR(new Layouts.Jar()),
|
||||
|
||||
/**
|
||||
* War Layout.
|
||||
*/
|
||||
WAR(new Layouts.War()),
|
||||
|
||||
/**
|
||||
* Zip Layout.
|
||||
*/
|
||||
ZIP(new Layouts.Expanded()),
|
||||
|
||||
/**
|
||||
* Dir Layout.
|
||||
*/
|
||||
DIR(new Layouts.Expanded()),
|
||||
|
||||
/**
|
||||
* Module Layout.
|
||||
*/
|
||||
MODULE(new Layouts.Module()),
|
||||
|
||||
/**
|
||||
* No Layout.
|
||||
*/
|
||||
NONE(new Layouts.None());
|
||||
|
||||
private static Map<String, Layout> customTypes;
|
||||
|
||||
private final Layout layout;
|
||||
|
||||
public Layout layout() {
|
||||
return this.layout;
|
||||
}
|
||||
|
||||
LayoutType(Layout layout) {
|
||||
this.layout = layout;
|
||||
}
|
||||
|
||||
public static Layout layout(String value) {
|
||||
try {
|
||||
return valueOf(value).layout();
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
if (customTypes == null) {
|
||||
customTypes = new HashMap<String, Layout>();
|
||||
lookupCustomTypes();
|
||||
}
|
||||
Layout layout = customTypes.get(value);
|
||||
if (layout == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot resolve custom layout type: " + value);
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
|
||||
private static void lookupCustomTypes() {
|
||||
ClassLoader classLoader = LayoutType.class.getClassLoader();
|
||||
List<LayoutFactory> factories = SpringFactoriesLoader
|
||||
.loadFactories(LayoutFactory.class, classLoader);
|
||||
for (LayoutFactory factory : factories) {
|
||||
customTypes.put(factory.getName(), factory.getLayout());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2015 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.loader.tools;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class LayoutTypeTests {
|
||||
|
||||
@Test
|
||||
public void standardType() {
|
||||
assertThat(LayoutType.layout("DIR"))
|
||||
.isEqualTo(LayoutType.valueOf("DIR").layout());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customType() {
|
||||
assertThat(LayoutType.layout("CUSTOM")).isNotNull();
|
||||
}
|
||||
|
||||
public static class TestLayoutFactory implements LayoutFactory {
|
||||
|
||||
@Override
|
||||
public Layout getLayout() {
|
||||
return new Layouts.Jar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CUSTOM";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
org.springframework.boot.loader.tools.LayoutFactory=\
|
||||
org.springframework.boot.loader.tools.LayoutTypeTests.TestLayoutFactory
|
@ -1,57 +0,0 @@
|
||||
-----
|
||||
Use a custom layout
|
||||
-----
|
||||
Dave Syer
|
||||
-----
|
||||
2016-10-30
|
||||
-----
|
||||
|
||||
Spring Boot repackages the jar file for this project using a custom
|
||||
layout defined in the additional jar file, provided as a dependency
|
||||
to the build plugin:
|
||||
|
||||
---
|
||||
<project>
|
||||
...
|
||||
<build>
|
||||
...
|
||||
<plugins>
|
||||
...
|
||||
<plugin>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<layout>CUSTOM</layout>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>custom-layout</artifactId>
|
||||
<version>0.0.1.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
...
|
||||
</plugin>
|
||||
...
|
||||
</plugins>
|
||||
...
|
||||
</build>
|
||||
...
|
||||
</project>
|
||||
---
|
||||
|
||||
The layout is provided as an implementation of <<LayoutFactory>>
|
||||
(from spring-boot-loader-tools) listed in
|
||||
<<META-INF/spring-factories>> inside the <<custom-layout>> jar.
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue