diff --git a/spring-boot-cli/pom.xml b/spring-boot-cli/pom.xml index 82e499f1c5..d03f1885ef 100644 --- a/spring-boot-cli/pom.xml +++ b/spring-boot-cli/pom.xml @@ -122,6 +122,11 @@ junit provided + + org.springframework.integration + spring-integration-core + provided + ${project.groupId} diff --git a/spring-boot-cli/samples/integration.groovy b/spring-boot-cli/samples/integration.groovy new file mode 100644 index 0000000000..13d846f186 --- /dev/null +++ b/spring-boot-cli/samples/integration.groovy @@ -0,0 +1,26 @@ +package org.test + +@Component +@EnableIntegrationPatterns +class SpringIntegrationExample implements CommandLineRunner { + + @Bean + DirectChannel input() { + new DirectChannel(); + } + + @Override + void run(String... args) { + print new MessagingTemplate(input()).convertSendAndReceive("World") + } +} + +@MessageEndpoint +class HelloTransformer { + + @Transformer(inputChannel="input") + String transform(String payload) { + "Hello, ${payload}" + } + +} \ No newline at end of file diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java index 442f1be9f5..95982d1122 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/autoconfigure/SpringIntegrationCompilerAutoConfiguration.java @@ -41,7 +41,7 @@ public class SpringIntegrationCompilerAutoConfiguration extends CompilerAutoConf @Override public void applyDependencies(DependencyCustomizer dependencies) { dependencies.ifAnyMissingClasses("org.springframework.integration.Message").add( - "spring-boot-starter-integration", "spring-integration-dsl-groovy-core"); + "spring-boot-starter-integration"); dependencies.ifAnyMissingClasses("groovy.util.XmlParser").add("groovy-xml"); } @@ -50,14 +50,14 @@ public class SpringIntegrationCompilerAutoConfiguration extends CompilerAutoConf imports.addImports("org.springframework.integration.Message", "org.springframework.integration.support.MessageBuilder", "org.springframework.integration.MessageChannel", + "org.springframework.integration.channel.DirectChannel", + "org.springframework.integration.channel.QueueChannel", + "org.springframework.integration.channel.ExecutorChannel", "org.springframework.integration.MessageHeaders", - "org.springframework.integration.annotation.MessageEndpoint", - "org.springframework.integration.annotation.Header", - "org.springframework.integration.annotation.Headers", - "org.springframework.integration.annotation.Payload", - "org.springframework.integration.annotation.Payloads", - "org.springframework.integration.dsl.groovy.MessageFlow", - "org.springframework.integration.dsl.groovy.builder.IntegrationBuilder", + "org.springframework.integration.core.MessagingTemplate", + "org.springframework.integration.core.SubscribableChannel", + "org.springframework.integration.core.PollableChannel", EnableIntegrationPatterns.class.getCanonicalName()); + imports.addStarImports("org.springframework.integration.annotation"); } } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/groovy/EnableIntegrationPatterns.java b/spring-boot-cli/src/main/java/org/springframework/boot/groovy/EnableIntegrationPatterns.java index ff40972ecf..d4be1ee03c 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/groovy/EnableIntegrationPatterns.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/groovy/EnableIntegrationPatterns.java @@ -22,9 +22,14 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + @Target(ElementType.TYPE) @Documented @Retention(RetentionPolicy.RUNTIME) +@Configuration +@ImportResource("classpath:/org/springframework/boot/groovy/integration.xml") public @interface EnableIntegrationPatterns { } \ No newline at end of file diff --git a/spring-boot-cli/src/main/resources/org/springframework/boot/groovy/integration.xml b/spring-boot-cli/src/main/resources/org/springframework/boot/groovy/integration.xml new file mode 100644 index 0000000000..3e0c0953df --- /dev/null +++ b/spring-boot-cli/src/main/resources/org/springframework/boot/groovy/integration.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java index 369a554b39..a277ee3773 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java @@ -121,6 +121,12 @@ public class SampleIntegrationTests { assertTrue("Wrong output: " + output, output.contains("Hello World")); } + @Test + public void integrationSample() throws Exception { + String output = this.cli.run("integration.groovy"); + assertTrue("Wrong output: " + output, output.contains("Hello, World")); + } + @Test public void xmlSample() throws Exception { String output = this.cli.run("runner.xml", "runner.groovy");