diff --git a/spring-platform-cli/src/main/java/org/springframework/platform/cli/compiler/ConfigServerCompilerAutoConfiguration.java b/spring-platform-cli/src/main/java/org/springframework/platform/cli/compiler/ConfigServerCompilerAutoConfiguration.java new file mode 100644 index 0000000..509b1df --- /dev/null +++ b/spring-platform-cli/src/main/java/org/springframework/platform/cli/compiler/ConfigServerCompilerAutoConfiguration.java @@ -0,0 +1,48 @@ +/* + * Copyright 2013-2014 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.platform.cli.compiler; + +import org.codehaus.groovy.ast.ClassNode; +import org.codehaus.groovy.control.CompilationFailedException; +import org.codehaus.groovy.control.customizers.ImportCustomizer; +import org.springframework.boot.cli.compiler.AstUtils; +import org.springframework.boot.cli.compiler.CompilerAutoConfiguration; +import org.springframework.boot.cli.compiler.DependencyCustomizer; + +/** + * @author Dave Syer + * + */ +public class ConfigServerCompilerAutoConfiguration extends CompilerAutoConfiguration { + + @Override + public boolean matches(ClassNode classNode) { + return AstUtils.hasAtLeastOneAnnotation(classNode, "EnableConfigServer"); + } + + @Override + public void applyDependencies(DependencyCustomizer dependencies) { + dependencies + .ifAnyMissingClasses("org.springframework.platform.config.server.EnableConfigServer") + .add("spring-platform-config-server"); + } + + @Override + public void applyImports(ImportCustomizer imports) throws CompilationFailedException { + imports.addImports("org.springframework.platform.config.server.EnableConfigServer"); + } + +} diff --git a/spring-platform-cli/src/main/java/org/springframework/platform/cli/compiler/EurekaClientCompilerAutoConfiguration.java b/spring-platform-cli/src/main/java/org/springframework/platform/cli/compiler/EurekaClientCompilerAutoConfiguration.java new file mode 100644 index 0000000..274d950 --- /dev/null +++ b/spring-platform-cli/src/main/java/org/springframework/platform/cli/compiler/EurekaClientCompilerAutoConfiguration.java @@ -0,0 +1,48 @@ +/* + * Copyright 2013-2014 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.platform.cli.compiler; + +import org.codehaus.groovy.ast.ClassNode; +import org.codehaus.groovy.control.CompilationFailedException; +import org.codehaus.groovy.control.customizers.ImportCustomizer; +import org.springframework.boot.cli.compiler.AstUtils; +import org.springframework.boot.cli.compiler.CompilerAutoConfiguration; +import org.springframework.boot.cli.compiler.DependencyCustomizer; + +/** + * @author Dave Syer + * + */ +public class EurekaClientCompilerAutoConfiguration extends CompilerAutoConfiguration { + + @Override + public boolean matches(ClassNode classNode) { + return AstUtils.hasAtLeastOneAnnotation(classNode, "EnableEurekaClient"); + } + + @Override + public void applyDependencies(DependencyCustomizer dependencies) { + dependencies + .ifAnyMissingClasses("org.springframework.platform.netflix.eureka.EnableEurekaClient") + .add("spring-platform-starter-eureka"); + } + + @Override + public void applyImports(ImportCustomizer imports) throws CompilationFailedException { + imports.addImports("org.springframework.platform.netflix.eureka.EnableEurekaClient", "com.netflix.discovery.DiscoveryClient"); + } + +} diff --git a/spring-platform-cli/src/main/java/org/springframework/platform/cli/compiler/HystrixCompilerAutoConfiguration.java b/spring-platform-cli/src/main/java/org/springframework/platform/cli/compiler/HystrixCompilerAutoConfiguration.java new file mode 100644 index 0000000..c797aa0 --- /dev/null +++ b/spring-platform-cli/src/main/java/org/springframework/platform/cli/compiler/HystrixCompilerAutoConfiguration.java @@ -0,0 +1,51 @@ +/* + * Copyright 2013-2014 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.platform.cli.compiler; + +import org.codehaus.groovy.ast.ClassNode; +import org.codehaus.groovy.control.CompilationFailedException; +import org.codehaus.groovy.control.customizers.ImportCustomizer; +import org.springframework.boot.cli.compiler.AstUtils; +import org.springframework.boot.cli.compiler.CompilerAutoConfiguration; +import org.springframework.boot.cli.compiler.DependencyCustomizer; + +/** + * @author Dave Syer + * + */ +public class HystrixCompilerAutoConfiguration extends CompilerAutoConfiguration { + + @Override + public boolean matches(ClassNode classNode) { + return AstUtils.hasAtLeastOneAnnotation(classNode, "EnableHystrix"); + } + + @Override + public void applyDependencies(DependencyCustomizer dependencies) { + dependencies.ifAnyMissingClasses( + "org.springframework.platform.netflix.hystrix.annotations.EnableHystrix") + .add("spring-platform-starter-hystrix"); + } + + @Override + public void applyImports(ImportCustomizer imports) throws CompilationFailedException { + imports.addImports( + "org.springframework.platform.netflix.hystrix.annotations.EnableHystrix", + "com.netflix.hystrix.contrib.javanica.annotation.HystrixCollapser", + "com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand"); + } + +} diff --git a/spring-platform-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration b/spring-platform-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration index a2d871c..7c43524 100644 --- a/spring-platform-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration +++ b/spring-platform-cli/src/main/resources/META-INF/services/org.springframework.boot.cli.compiler.CompilerAutoConfiguration @@ -1 +1,4 @@ -org.springframework.platform.cli.compiler.SpringPlatformCompilerAutoConfiguration \ No newline at end of file +org.springframework.platform.cli.compiler.SpringPlatformCompilerAutoConfiguration +org.springframework.platform.cli.compiler.ConfigServerCompilerAutoConfiguration +org.springframework.platform.cli.compiler.EurekaClientCompilerAutoConfiguration +org.springframework.platform.cli.compiler.HystrixCompilerAutoConfiguration \ No newline at end of file diff --git a/spring-platform-versions/pom.xml b/spring-platform-versions/pom.xml index 1984f56..1601ba1 100644 --- a/spring-platform-versions/pom.xml +++ b/spring-platform-versions/pom.xml @@ -30,6 +30,11 @@ spring-platform-starter-eureka ${project.version} + + org.springframework.platform + spring-platform-starter-hystrix + ${project.version} +