Moving the project to a multi-level maven project to allow for separation of the adapter from the core of the project

Fixes #28
This commit is contained in:
camilojc
2017-05-17 22:59:54 +01:00
committed by Eric Bottard
parent 3313140ecb
commit 9ca98cdd7d
65 changed files with 295 additions and 48 deletions

21
.gitignore vendored
View File

@@ -1,17 +1,10 @@
/.classpath
/.project
.classpath
.project
.settings/
.gradle
build
target/
/log.roo
/bin/
/*.log
/.idea
/*.iml
/*.ipr
/*.iws
out
.gradletasknamecache
.idea/
*.iml
*.ipr
*.iws

View File

@@ -13,7 +13,9 @@ while maintaining some level of backward compatibility with your existing comman
*Note:* the dummy commands that are currently available are not here to stay. Expect a more modular
setup in the future. In the meantime, to get a grasp of how the shell would behave, you can
```
./mvnw spring-boot:run
# if using a local snapshot version
./mvnw install
./mvnw -pl spring-shell2-samples spring-boot:run
```
From there, try typing `help` at the shell prompt.

64
pom.xml
View File

@@ -3,18 +3,48 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<packaging>jar</packaging>
<artifactId>spring-shell2-parent</artifactId>
<version>2.0.0-BUILD.SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version>
</parent>
<properties>
<jline.version>3.3.0</jline.version>
<assertj.version>3.2.0</assertj.version>
<java.version>1.8</java.version>
</properties>
<modules>
<module>spring-shell2-core</module>
<module>spring-shell2-jcommander-adapter</module>
<module>spring-shell2-samples</module>
<module>spring-shell2-shell1-adapter</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-shell1-adapter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-jcommander-adapter</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
@@ -32,34 +62,26 @@
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell</artifactId>
<version>1.2.0.BUILD-SNAPSHOT</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.48</version>
<optional>true</optional>
<version>${jline.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.2.0</version>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>

View File

@@ -0,0 +1,16 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-shell2-core</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<version>2.0.0-BUILD.SNAPSHOT</version>
</parent>
<description>Core API and classes for Spring Shell 2</description>
</project>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-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.
@@ -26,12 +26,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.shell.converters.ArrayConverter;
import org.springframework.shell.converters.AvailableCommandsConverter;
import org.springframework.shell.converters.SimpleFileConverter;
import org.springframework.shell2.standard.EnumValueProvider;
import org.springframework.shell2.standard.StandardParameterResolver;
@@ -41,11 +37,10 @@ import org.springframework.shell2.standard.StandardParameterResolver;
* <p>Creates the application context and start the REPL.</p>
*
* @author Eric Bottard
* @author Camilo Gonzalez
*/
@SpringBootApplication
@ComponentScan(basePackageClasses = {ArrayConverter.class, Bootstrap.class}, excludeFilters = @ComponentScan.Filter(
type = FilterType.ASSIGNABLE_TYPE,
value = {AvailableCommandsConverter.class, SimpleFileConverter.class}))
@ComponentScan(basePackageClasses = Bootstrap.class)
public class Bootstrap {
public static void main(String[] args) throws Exception {

View File

@@ -0,0 +1,28 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-shell2-jcommander-adapter</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<version>2.0.0-BUILD.SNAPSHOT</version>
</parent>
<description>Adapter classes to allow JCommander type annotations and parsing via Spring Shell 2</description>
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core</artifactId>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.48</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,43 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-shell2-samples</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<version>2.0.0-BUILD.SNAPSHOT</version>
</parent>
<description>Examples of using Spring Shell 2</description>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>org.springframework.shell2.Bootstrap</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-shell1-adapter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-jcommander-adapter</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,25 @@
/*
* Copyright 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.shell2.samples.legacy;
/**
* Created by ericbottard on 09/12/15.
*/
public enum ArtifactType {
source, processor, sink, task
}

View File

@@ -0,0 +1,61 @@
/*
* Copyright 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.shell2.samples.legacy;
import java.lang.reflect.Method;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.shell.core.annotation.CliOption;
import org.springframework.util.ReflectionUtils;
/**
* Created by ericbottard on 09/12/15.
*/
public class LegacyCommands implements CommandMarker {
public static final Method REGISTER_METHOD = ReflectionUtils.findMethod(LegacyCommands.class, "register", String.class, ArtifactType.class, String.class, boolean.class);
public static final Method SUM_METHOD = ReflectionUtils.findMethod(LegacyCommands.class, "sum", int.class, int.class);
@CliCommand(value = "register module", help = "Register a new module")
public String register(
@CliOption(mandatory = true,
key = {"", "name"},
help = "the name for the registered module")
String name,
@CliOption(mandatory = true,
key = {"type"},
help = "the type for the registered module")
ArtifactType type,
@CliOption(mandatory = true,
key = {"coordinates", "coords"},
help = "coordinates to the module archive")
String coordinates,
@CliOption(key = "force",
help = "force update if module already exists (only if not in use)",
specifiedDefaultValue = "true",
unspecifiedDefaultValue = "false")
boolean force) {
return String.format(("Successfully registered module '%s:%s'"), type, name);
}
@CliCommand(value = "sum", help = "adds two numbers")
public int sum(@CliOption(key = "v1", unspecifiedDefaultValue = "38") int a, @CliOption(key = "v2", specifiedDefaultValue = "42") int b) {
return a + b;
}
}

View File

@@ -14,15 +14,13 @@
* limitations under the License.
*/
package org.springframework.shell2;
package org.springframework.shell2.samples.standard;
import org.springframework.shell2.standard.ShellComponent;
import org.springframework.shell2.standard.ShellMethod;
/**
* Example commands for easy testing.
*
* To be removed in final project.
* Example commands for the Shell 2 Standard resolver.
*
* @author Eric Bottard
*/

View File

@@ -0,0 +1,28 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-shell2-shell1-adapter</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-parent</artifactId>
<version>2.0.0-BUILD.SNAPSHOT</version>
</parent>
<description>Adapter classes to enable Shell 1 type annotations via Spring Shell 2</description>
<dependencies>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell2-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,36 @@
/*
* Copyright 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.
* 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.shell2.legacy;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.shell.converters.ArrayConverter;
import org.springframework.shell.converters.AvailableCommandsConverter;
import org.springframework.shell.converters.SimpleFileConverter;
/**
* Main configuration class for the Shell 2 - Shell 1 adapter.
*
* @author Camilo Gonzalez
*/
@Configuration
@ComponentScan(basePackageClasses = {ArrayConverter.class}, excludeFilters = @ComponentScan.Filter(
type = FilterType.ASSIGNABLE_TYPE,
value = {AvailableCommandsConverter.class, SimpleFileConverter.class}))
public class LegacyConfiguration {
}