deploymentProperties = KeyValueListParser.parseCommaDelimitedKeyValuePairs(
88 | "app.sftp.param=value1,value2,app.sftp.other.param=other1,other2");
89 |
90 | assertTrue("Invalid number of deployment properties: " + deploymentProperties.size(),
91 | deploymentProperties.size() == 2);
92 | assertTrue("Expected deployment key not found", deploymentProperties.containsKey("app.sftp.param"));
93 | assertEquals("Invalid deployment value", "value1,value2", deploymentProperties.get("app.sftp.param"));
94 | assertTrue("Expected deployment key not found", deploymentProperties.containsKey("app.sftp.other.param"));
95 | assertEquals("Invalid deployment value", "other1,other2", deploymentProperties.get("app.sftp.other.param"));
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/common/stream-apps-metadata-store-common/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | stream-apps-common
9 | org.springframework.cloud.stream.app
10 | 3.0.0.BUILD-SNAPSHOT
11 |
12 |
13 | stream-apps-metadata-store-common
14 | stream-apps-metadata-store-common
15 |
16 |
17 | 1.11.439
18 | 2.0.0.RELEASE
19 | 1.0.0.RELEASE
20 | 4.0.1
21 |
22 |
23 |
24 |
25 |
26 | org.springframework.integration
27 | spring-integration-core
28 |
29 |
30 |
31 |
32 | org.springframework.integration
33 | spring-integration-redis
34 | true
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-starter-data-redis
39 | true
40 |
41 |
42 |
43 |
44 | org.springframework.integration
45 | spring-integration-mongodb
46 | true
47 |
48 |
49 | org.springframework.boot
50 | spring-boot-starter-data-mongodb
51 | true
52 |
53 |
54 | de.flapdoodle.embed
55 | de.flapdoodle.embed.mongo
56 | test
57 |
58 |
59 |
60 |
61 | org.springframework.boot
62 | spring-boot-starter-logging
63 | true
64 |
65 |
66 | org.apache.logging.log4j
67 | log4j-to-slf4j
68 |
69 |
70 |
71 |
72 | org.springframework.integration
73 | spring-integration-gemfire
74 | true
75 |
76 |
77 | org.springframework.data
78 | spring-data-gemfire
79 |
80 |
81 |
82 |
83 |
84 | org.springframework.data
85 | spring-data-geode
86 | true
87 |
88 |
93 |
94 |
95 |
96 | org.springframework.integration
97 | spring-integration-jdbc
98 | true
99 |
100 |
101 | org.springframework.boot
102 | spring-boot-starter-jdbc
103 | true
104 |
105 |
106 | org.hsqldb
107 | hsqldb
108 | test
109 |
110 |
111 |
112 |
113 | org.springframework.integration
114 | spring-integration-zookeeper
115 | true
116 |
117 |
118 | org.apache.curator
119 | curator-test
120 | ${curator.version}
121 | test
122 |
123 |
124 |
125 |
126 | org.springframework.integration
127 | spring-integration-hazelcast
128 | ${spring-integration-hazelcast.version}
129 | true
130 |
131 |
132 |
133 |
134 | org.springframework.integration
135 | spring-integration-aws
136 | ${spring-integration-aws.version}
137 | true
138 |
139 |
140 | com.amazonaws
141 | aws-java-sdk-dynamodb
142 | ${aws-java-sdk.version}
143 | true
144 |
145 |
146 | org.springframework.integration
147 | spring-integration-test
148 | test
149 |
150 |
151 |
152 |
153 |
--------------------------------------------------------------------------------
/common/stream-apps-test-support/src/main/java/org/springframework/cloud/stream/app/test/file/remote/RemoteFileTestSupport.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2016 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.cloud.stream.app.test.file.remote;
17 |
18 | import java.io.File;
19 | import java.io.FileOutputStream;
20 | import java.io.IOException;
21 |
22 | import org.junit.Before;
23 | import org.junit.ClassRule;
24 | import org.junit.rules.TemporaryFolder;
25 |
26 | /**
27 | * Abstract base class for tests requiring remote file servers, e.g. (S)FTP.
28 | *
29 | * @author Gary Russell
30 | *
31 | */
32 | public abstract class RemoteFileTestSupport {
33 |
34 | protected static final int port = 0;
35 |
36 | @ClassRule
37 | public static final TemporaryFolder remoteTemporaryFolder = new TemporaryFolder();
38 |
39 | @ClassRule
40 | public static final TemporaryFolder localTemporaryFolder = new TemporaryFolder();
41 |
42 | protected volatile File sourceRemoteDirectory;
43 |
44 | protected volatile File targetRemoteDirectory;
45 |
46 | protected volatile File sourceLocalDirectory;
47 |
48 | protected volatile File targetLocalDirectory;
49 |
50 | public File getSourceRemoteDirectory() {
51 | return sourceRemoteDirectory;
52 | }
53 |
54 | public File getTargetRemoteDirectory() {
55 | return targetRemoteDirectory;
56 | }
57 |
58 | public File getSourceLocalDirectory() {
59 | return sourceLocalDirectory;
60 | }
61 |
62 | public File getTargetLocalDirectory() {
63 | return targetLocalDirectory;
64 | }
65 |
66 | /**
67 | * Default implementation creates the following folder structures:
68 | *
69 | *
70 | * $ tree remoteSource/
71 | * remoteSource/
72 | * ├── remoteSource1.txt - contains 'source1'
73 | * ├── remoteSource2.txt - contains 'source2'
74 | * remoteTarget/
75 | * $ tree localSource/
76 | * localSource/
77 | * ├── localSource1.txt - contains 'local1'
78 | * ├── localSource2.txt - contains 'local2'
79 | * localTarget/
80 | *
81 | *
82 | * The intent is tests retrieve from remoteSource and verify arrival in localTarget or send from localSource and verify
83 | * arrival in remoteTarget.
84 | *
85 | * Subclasses can change 'remote' in these names by overriding {@link #prefix()} or override this method completely to
86 | * create a different structure.
87 | *
88 | * While a single server exists for all tests, the directory structure is rebuilt for each test.
89 | * @throws IOException IO Exception.
90 | */
91 | @Before
92 | public void setupFolders() throws IOException {
93 | String prefix = prefix();
94 | recursiveDelete(new File(remoteTemporaryFolder.getRoot(), prefix + "Source"));
95 | this.sourceRemoteDirectory = remoteTemporaryFolder.newFolder(prefix + "Source");
96 | recursiveDelete(new File(remoteTemporaryFolder.getRoot(), prefix + "Target"));
97 | this.targetRemoteDirectory = remoteTemporaryFolder.newFolder(prefix + "Target");
98 | recursiveDelete(new File(localTemporaryFolder.getRoot(), "localSource"));
99 | this.sourceLocalDirectory = localTemporaryFolder.newFolder("localSource");
100 | recursiveDelete(new File(localTemporaryFolder.getRoot(), "localTarget"));
101 | this.targetLocalDirectory = localTemporaryFolder.newFolder("localTarget");
102 | File file = new File(sourceRemoteDirectory, prefix + "Source1.txt");
103 | file.createNewFile();
104 | FileOutputStream fos = new FileOutputStream(file);
105 | fos.write("source1".getBytes());
106 | fos.close();
107 | file = new File(sourceRemoteDirectory, prefix + "Source2.txt");
108 | file.createNewFile();
109 | fos = new FileOutputStream(file);
110 | fos.write("source2".getBytes());
111 | fos.close();
112 | file = new File(sourceLocalDirectory, "localSource1.txt");
113 | file.createNewFile();
114 | fos = new FileOutputStream(file);
115 | fos.write("local1".getBytes());
116 | fos.close();
117 | file = new File(sourceLocalDirectory, "localSource2.txt");
118 | file.createNewFile();
119 | fos = new FileOutputStream(file);
120 | fos.write("local2".getBytes());
121 | fos.close();
122 | }
123 |
124 | public void recursiveDelete(File file) {
125 | if (file != null && file.exists()) {
126 | File[] files = file.listFiles();
127 | if (files != null) {
128 | for (File fyle : files) {
129 | if (fyle.isDirectory()) {
130 | recursiveDelete(fyle);
131 | }
132 | else {
133 | fyle.delete();
134 | }
135 | }
136 | }
137 | file.delete();
138 | }
139 | }
140 |
141 | /**
142 | * Prefix for directory/file structure; default 'remote'.
143 | * @return the prefix.
144 | */
145 | protected String prefix() {
146 | return "remote";
147 | }
148 |
149 | }
150 |
--------------------------------------------------------------------------------
/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | set MAVEN_CMD_LINE_ARGS=%*
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 |
121 | set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
123 |
124 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
125 | if ERRORLEVEL 1 goto error
126 | goto end
127 |
128 | :error
129 | set ERROR_CODE=1
130 |
131 | :end
132 | @endlocal & set ERROR_CODE=%ERROR_CODE%
133 |
134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
138 | :skipRcPost
139 |
140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
142 |
143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
144 |
145 | exit /B %ERROR_CODE%
146 |
--------------------------------------------------------------------------------
/common/stream-apps-metadata-store-common/src/test/java/org/springframework/cloud/stream/app/metadata/MetadataStoreAutoConfigurationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 the original author or authors.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * https://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | package org.springframework.cloud.stream.app.metadata;
17 |
18 | import static org.assertj.core.api.Assertions.assertThat;
19 | import static org.mockito.ArgumentMatchers.any;
20 | import static org.mockito.BDDMockito.willReturn;
21 | import static org.mockito.Mockito.mock;
22 |
23 | import java.beans.Introspector;
24 | import java.nio.charset.StandardCharsets;
25 | import java.util.Arrays;
26 | import java.util.List;
27 | import java.util.function.Predicate;
28 |
29 | import org.apache.curator.test.TestingServer;
30 | import org.junit.Ignore;
31 | import org.junit.Test;
32 | import org.junit.runner.RunWith;
33 | import org.junit.runners.Parameterized;
34 |
35 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
36 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
37 | import org.springframework.boot.test.context.FilteredClassLoader;
38 | import org.springframework.boot.test.context.runner.ApplicationContextRunner;
39 | import org.springframework.cloud.aws.core.region.RegionProvider;
40 | import org.springframework.context.annotation.Bean;
41 | import org.springframework.context.annotation.Configuration;
42 | import org.springframework.integration.aws.metadata.DynamoDbMetadataStore;
43 | import org.springframework.integration.gemfire.metadata.GemfireMetadataStore;
44 | import org.springframework.integration.hazelcast.metadata.HazelcastMetadataStore;
45 | import org.springframework.integration.jdbc.metadata.JdbcMetadataStore;
46 | import org.springframework.integration.metadata.ConcurrentMetadataStore;
47 | import org.springframework.integration.metadata.MetadataStore;
48 | import org.springframework.integration.metadata.SimpleMetadataStore;
49 | import org.springframework.integration.mongodb.metadata.MongoDbMetadataStore;
50 | import org.springframework.integration.redis.metadata.RedisMetadataStore;
51 | import org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStore;
52 |
53 | import com.amazonaws.auth.AWSCredentialsProvider;
54 | import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync;
55 | import com.amazonaws.services.dynamodbv2.model.DescribeTableRequest;
56 | import com.amazonaws.services.dynamodbv2.model.DescribeTableResult;
57 |
58 | /**
59 | * @author Artem Bilan
60 | *
61 | * @since 2.0.2
62 | */
63 | @RunWith(Parameterized.class)
64 | @Ignore
65 | public class MetadataStoreAutoConfigurationTests {
66 |
67 | private final static List> METADATA_STORE_CLASSES =
68 | Arrays.asList(
69 | RedisMetadataStore.class,
70 | MongoDbMetadataStore.class,
71 | GemfireMetadataStore.class,
72 | JdbcMetadataStore.class,
73 | ZookeeperMetadataStore.class,
74 | HazelcastMetadataStore.class,
75 | DynamoDbMetadataStore.class,
76 | SimpleMetadataStore.class
77 | );
78 |
79 | private static FilteredClassLoader filteredClassLoaderBut(Class extends ConcurrentMetadataStore> classToInclude) {
80 | return new FilteredClassLoader(
81 | METADATA_STORE_CLASSES.stream()
82 | .filter(Predicate.isEqual(classToInclude).negate())
83 | .toArray(Class>[]::new));
84 | }
85 |
86 | private final ApplicationContextRunner contextRunner;
87 |
88 | private final Class extends ConcurrentMetadataStore> classToInclude;
89 |
90 |
91 | public MetadataStoreAutoConfigurationTests(Class extends ConcurrentMetadataStore> classToInclude) {
92 | this.classToInclude = classToInclude;
93 | this.contextRunner =
94 | new ApplicationContextRunner()
95 | .withUserConfiguration(TestConfiguration.class)
96 | .withClassLoader(filteredClassLoaderBut(classToInclude));
97 | }
98 |
99 | @Parameterized.Parameters
100 | public static Iterable> parameters() {
101 | return METADATA_STORE_CLASSES;
102 | }
103 |
104 | @Test
105 | public void testMetadataStore() {
106 | this.contextRunner
107 | .run(context -> {
108 | assertThat(context.getBeansOfType(MetadataStore.class)).hasSize(1);
109 |
110 | assertThat(context.getBeanNamesForType(this.classToInclude))
111 | .containsOnlyOnce(Introspector.decapitalize(this.classToInclude.getSimpleName()));
112 | });
113 | }
114 |
115 | @Configuration
116 | @EnableAutoConfiguration
117 | public static class TestConfiguration {
118 |
119 | @Bean(destroyMethod = "stop")
120 | @ConditionalOnClass(ZookeeperMetadataStore.class)
121 | public static TestingServer zookeeperTestingServer() throws Exception {
122 | TestingServer testingServer = new TestingServer(true);
123 |
124 | System.setProperty("metadata.store.zookeeper.connect-string", testingServer.getConnectString());
125 | System.setProperty("metadata.store.zookeeper.encoding", StandardCharsets.US_ASCII.name());
126 |
127 | return testingServer;
128 | }
129 |
130 | @Configuration
131 | @ConditionalOnClass(DynamoDbMetadataStore.class)
132 | protected static class DynamoDbMockConfig {
133 |
134 | @Bean
135 | public static AmazonDynamoDBAsync dynamoDB() {
136 | AmazonDynamoDBAsync dynamoDb = mock(AmazonDynamoDBAsync.class);
137 | willReturn(new DescribeTableResult())
138 | .given(dynamoDb)
139 | .describeTable(any(DescribeTableRequest.class));
140 |
141 | return dynamoDb;
142 | }
143 |
144 | @Bean
145 | public static AWSCredentialsProvider awsCredentialsProvider() {
146 | return mock(AWSCredentialsProvider.class);
147 | }
148 |
149 | @Bean
150 | public static RegionProvider regionProvider() {
151 | return mock(RegionProvider.class);
152 | }
153 |
154 | }
155 |
156 | }
157 |
158 | }
159 |
--------------------------------------------------------------------------------
/common/stream-apps-task-launch-request-common/src/main/java/org/springframework/cloud/stream/app/tasklaunchrequest/DataFlowTaskLaunchRequestAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.cloud.stream.app.tasklaunchrequest;
18 |
19 | import java.util.ArrayList;
20 | import java.util.Collection;
21 | import java.util.HashMap;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 |
26 | import javax.annotation.PostConstruct;
27 | import org.apache.commons.logging.Log;
28 | import org.apache.commons.logging.LogFactory;
29 | import org.springframework.beans.factory.BeanFactory;
30 | import org.springframework.beans.factory.annotation.Autowired;
31 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
32 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
33 | import org.springframework.cloud.stream.app.tasklaunchrequest.support.CommandLineArgumentsMessageMapper;
34 | import org.springframework.cloud.stream.app.tasklaunchrequest.support.TaskLaunchRequestSupplier;
35 | import org.springframework.cloud.stream.app.tasklaunchrequest.support.TaskNameMessageMapper;
36 | import org.springframework.context.annotation.Bean;
37 | import org.springframework.context.annotation.Configuration;
38 | import org.springframework.expression.EvaluationContext;
39 | import org.springframework.expression.Expression;
40 | import org.springframework.expression.spel.standard.SpelExpressionParser;
41 | import org.springframework.integration.expression.ExpressionUtils;
42 | import org.springframework.messaging.Message;
43 | import org.springframework.util.StringUtils;
44 |
45 |
46 | /**
47 | * @author David Turanski
48 | **/
49 | @Configuration
50 | @EnableConfigurationProperties(DataflowTaskLaunchRequestProperties.class)
51 | public class DataFlowTaskLaunchRequestAutoConfiguration {
52 |
53 | @Autowired
54 | private BeanFactory beanFactory;
55 |
56 | private EvaluationContext evaluationContext;
57 |
58 | public final static String TASK_LAUNCH_REQUEST_FUNCTION_NAME = "taskLaunchRequest";
59 |
60 | /**
61 | * A {@link java.util.function.Function} to transform a {@link Message} payload to a {@link DataFlowTaskLaunchRequest}.
62 | *
63 | * @param taskLaunchRequestMessageProcessor a {@link TaskLaunchRequestMessageProcessor}.
64 | *
65 | * @return a {code DataFlowTaskLaunchRequest} Message.
66 | */
67 | @Bean(name = TASK_LAUNCH_REQUEST_FUNCTION_NAME)
68 | @ConditionalOnMissingBean(TaskLaunchRequestFunction.class)
69 | public TaskLaunchRequestFunction taskLaunchRequest(TaskLaunchRequestMessageProcessor taskLaunchRequestMessageProcessor) {
70 | return message -> taskLaunchRequestMessageProcessor.postProcessMessage(message);
71 | }
72 |
73 | @Bean
74 | @ConditionalOnMissingBean(TaskNameMessageMapper.class)
75 | public TaskNameMessageMapper taskNameMessageMapper(DataflowTaskLaunchRequestProperties taskLaunchRequestProperties) {
76 | if (StringUtils.hasText(taskLaunchRequestProperties.getTaskNameExpression())) {
77 | SpelExpressionParser expressionParser = new SpelExpressionParser();
78 | Expression taskNameExpression = expressionParser.parseExpression(taskLaunchRequestProperties.getTaskNameExpression());
79 | return new ExpressionEvaluatingTaskNameMessageMapper(taskNameExpression, this.evaluationContext);
80 | }
81 |
82 | return message -> taskLaunchRequestProperties.getTaskName();
83 | }
84 |
85 | @Bean
86 | @ConditionalOnMissingBean(CommandLineArgumentsMessageMapper.class)
87 | public CommandLineArgumentsMessageMapper commandLineArgumentsMessageMapper(
88 | DataflowTaskLaunchRequestProperties dataflowTaskLaunchRequestProperties){
89 |
90 | return new ExpressionEvaluatingCommandLineArgsMapper(dataflowTaskLaunchRequestProperties.getArgExpressions(),
91 | this.evaluationContext);
92 | }
93 |
94 | @Bean
95 | public TaskLaunchRequestSupplier taskLaunchRequestInitializer(
96 | DataflowTaskLaunchRequestProperties taskLaunchRequestProperties){
97 | return new DataflowTaskLaunchRequestPropertiesInitializer(taskLaunchRequestProperties);
98 | }
99 |
100 | @Bean
101 | public TaskLaunchRequestMessageProcessor taskLaunchRequestMessageProcessor(
102 | TaskLaunchRequestSupplier taskLaunchRequestInitializer,
103 | TaskNameMessageMapper taskNameMessageMapper,
104 | CommandLineArgumentsMessageMapper commandLineArgumentsMessageMapper) {
105 |
106 | return new TaskLaunchRequestMessageProcessor(taskLaunchRequestInitializer,
107 | taskNameMessageMapper,
108 | commandLineArgumentsMessageMapper);
109 | }
110 |
111 | static class DataflowTaskLaunchRequestPropertiesInitializer extends TaskLaunchRequestSupplier {
112 | DataflowTaskLaunchRequestPropertiesInitializer(
113 | DataflowTaskLaunchRequestProperties taskLaunchRequestProperties){
114 |
115 | this.commandLineArgumentSupplier(
116 | () -> new ArrayList<>(taskLaunchRequestProperties.getArgs())
117 | );
118 |
119 | this.deploymentPropertiesSupplier(
120 | () -> KeyValueListParser.parseCommaDelimitedKeyValuePairs(
121 | taskLaunchRequestProperties.getDeploymentProperties())
122 | );
123 |
124 | this.taskNameSupplier(()->taskLaunchRequestProperties.getTaskName());
125 | }
126 | }
127 |
128 | static class ExpressionEvaluatingCommandLineArgsMapper implements CommandLineArgumentsMessageMapper {
129 | private final Map argExpressionsMap;
130 | private final EvaluationContext evaluationContext;
131 |
132 | ExpressionEvaluatingCommandLineArgsMapper(String argExpressions, EvaluationContext evaluationContext) {
133 | this.evaluationContext = evaluationContext;
134 | this.argExpressionsMap = new HashMap<>();
135 | if (StringUtils.hasText(argExpressions)) {
136 | SpelExpressionParser expressionParser = new SpelExpressionParser();
137 |
138 | KeyValueListParser.parseCommaDelimitedKeyValuePairs(argExpressions).forEach(
139 | (k,v)-> argExpressionsMap.put(k, expressionParser.parseExpression(v)));
140 | }
141 |
142 | }
143 |
144 | @Override
145 | public Collection processMessage(Message> message) {
146 | return evaluateArgExpressions(message);
147 | }
148 |
149 | private Collection evaluateArgExpressions(Message> message) {
150 | List results = new LinkedList<>();
151 | this.argExpressionsMap.forEach((k, expression) ->
152 | results.add(String.format("%s=%s", k, expression.getValue(this.evaluationContext, message))));
153 | return results;
154 | }
155 | }
156 |
157 | @PostConstruct
158 | public void createEvaluationContext(){
159 | this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.beanFactory);
160 | }
161 |
162 | }
163 |
--------------------------------------------------------------------------------
/common/stream-apps-metadata-store-common/src/main/java/org/springframework/cloud/stream/app/metadata/MetadataStoreProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 the original author or authors.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * https://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | package org.springframework.cloud.stream.app.metadata;
17 |
18 | import java.nio.charset.Charset;
19 | import java.nio.charset.StandardCharsets;
20 |
21 | import org.springframework.boot.context.properties.ConfigurationProperties;
22 | import org.springframework.integration.aws.metadata.DynamoDbMetadataStore;
23 | import org.springframework.integration.gemfire.metadata.GemfireMetadataStore;
24 | import org.springframework.integration.jdbc.metadata.JdbcMetadataStore;
25 | import org.springframework.integration.redis.metadata.RedisMetadataStore;
26 |
27 | /**
28 | * @author Artem Bilan
29 | *
30 | * @since 2.0.2
31 | */
32 | @ConfigurationProperties("metadata.store")
33 | public class MetadataStoreProperties {
34 |
35 | private final Mongo mongoDb = new Mongo();
36 |
37 | private final Gemfire gemfire = new Gemfire();
38 |
39 | private final Redis redis = new Redis();
40 |
41 | private final DynamoDb dynamoDb = new DynamoDb();
42 |
43 | private final Jdbc jdbc = new Jdbc();
44 |
45 | private final Zookeeper zookeeper = new Zookeeper();
46 |
47 | public Mongo getMongoDb() {
48 | return this.mongoDb;
49 | }
50 |
51 | public Gemfire getGemfire() {
52 | return this.gemfire;
53 | }
54 |
55 | public Redis getRedis() {
56 | return this.redis;
57 | }
58 |
59 | public DynamoDb getDynamoDb() {
60 | return this.dynamoDb;
61 | }
62 |
63 | public Jdbc getJdbc() {
64 | return this.jdbc;
65 | }
66 |
67 | public Zookeeper getZookeeper() {
68 | return this.zookeeper;
69 | }
70 |
71 | public static class Mongo {
72 |
73 | /**
74 | * MongoDB collection name for metadata.
75 | */
76 | private String collection = "metadataStore";
77 |
78 | public String getCollection() {
79 | return this.collection;
80 | }
81 |
82 | public void setCollection(String collection) {
83 | this.collection = collection;
84 | }
85 |
86 | }
87 |
88 | public static class Gemfire {
89 |
90 | /**
91 | * Gemfire region name for metadata.
92 | */
93 | private String region = GemfireMetadataStore.KEY;
94 |
95 | public String getRegion() {
96 | return this.region;
97 | }
98 |
99 | public void setRegion(String region) {
100 | this.region = region;
101 | }
102 |
103 | }
104 |
105 | public static class Redis {
106 |
107 | /**
108 | * Redis key for metadata.
109 | */
110 | private String key = RedisMetadataStore.KEY;
111 |
112 | public String getKey() {
113 | return this.key;
114 | }
115 |
116 | public void setKey(String key) {
117 | this.key = key;
118 | }
119 |
120 | }
121 |
122 | public static class DynamoDb {
123 |
124 | /**
125 | * Table name for metadata.
126 | */
127 | private String table = DynamoDbMetadataStore.DEFAULT_TABLE_NAME;
128 |
129 | /**
130 | * Read capacity on the table.
131 | */
132 | private long readCapacity = 1L;
133 |
134 | /**
135 | * Write capacity on the table.
136 | */
137 | private long writeCapacity = 1L;
138 |
139 | /**
140 | * Delay between create table retries.
141 | */
142 | private int createDelay = 1;
143 |
144 | /**
145 | * Retry number for create table request.
146 | */
147 | private int createRetries = 25;
148 |
149 | /**
150 | * TTL for table entries.
151 | */
152 | private Integer timeToLive;
153 |
154 | public String getTable() {
155 | return this.table;
156 | }
157 |
158 | public void setTable(String table) {
159 | this.table = table;
160 | }
161 |
162 | public long getReadCapacity() {
163 | return this.readCapacity;
164 | }
165 |
166 | public void setReadCapacity(long readCapacity) {
167 | this.readCapacity = readCapacity;
168 | }
169 |
170 | public long getWriteCapacity() {
171 | return this.writeCapacity;
172 | }
173 |
174 | public void setWriteCapacity(long writeCapacity) {
175 | this.writeCapacity = writeCapacity;
176 | }
177 |
178 | public int getCreateDelay() {
179 | return this.createDelay;
180 | }
181 |
182 | public void setCreateDelay(int createDelay) {
183 | this.createDelay = createDelay;
184 | }
185 |
186 | public int getCreateRetries() {
187 | return this.createRetries;
188 | }
189 |
190 | public void setCreateRetries(int createRetries) {
191 | this.createRetries = createRetries;
192 | }
193 |
194 | public Integer getTimeToLive() {
195 | return this.timeToLive;
196 | }
197 |
198 | public void setTimeToLive(Integer timeToLive) {
199 | this.timeToLive = timeToLive;
200 | }
201 |
202 | }
203 |
204 | public static class Jdbc {
205 |
206 | /**
207 | * Prefix for the custom table name.
208 | */
209 | private String tablePrefix = JdbcMetadataStore.DEFAULT_TABLE_PREFIX;
210 |
211 | /**
212 | * Unique grouping identifier for messages persisted with this store.
213 | */
214 | private String region = "DEFAULT";
215 |
216 | public String getTablePrefix() {
217 | return this.tablePrefix;
218 | }
219 |
220 | public void setTablePrefix(String tablePrefix) {
221 | this.tablePrefix = tablePrefix;
222 | }
223 |
224 | public String getRegion() {
225 | return this.region;
226 | }
227 |
228 | public void setRegion(String region) {
229 | this.region = region;
230 | }
231 |
232 | }
233 |
234 | public static class Zookeeper {
235 |
236 | /**
237 | * Zookeeper connect string in form HOST:PORT.
238 | */
239 | private String connectString = "127.0.0.1:2181";
240 |
241 | /**
242 | * Retry interval for Zookeeper operations in milliseconds.
243 | */
244 | private int retryInterval = 1000;
245 |
246 | /**
247 | * Encoding to use when storing data in Zookeeper.
248 | */
249 | private Charset encoding = StandardCharsets.UTF_8;
250 |
251 | /**
252 | * Root node - store entries are children of this node.
253 | */
254 | private String root = "/SpringIntegration-MetadataStore";
255 |
256 | public String getConnectString() {
257 | return connectString;
258 | }
259 |
260 | public void setConnectString(String connectString) {
261 | this.connectString = connectString;
262 | }
263 |
264 | public int getRetryInterval() {
265 | return this.retryInterval;
266 | }
267 |
268 | public void setRetryInterval(int retryInterval) {
269 | this.retryInterval = retryInterval;
270 | }
271 |
272 | public Charset getEncoding() {
273 | return this.encoding;
274 | }
275 |
276 | public void setEncoding(Charset encoding) {
277 | this.encoding = encoding;
278 | }
279 |
280 | public String getRoot() {
281 | return this.root;
282 | }
283 |
284 | public void setRoot(String root) {
285 | this.root = root;
286 | }
287 |
288 | }
289 |
290 | }
291 |
--------------------------------------------------------------------------------
/common/stream-apps-metadata-store-common/README.adoc:
--------------------------------------------------------------------------------
1 | === `MetadataStore` Common Module
2 |
3 | This artifact contains a Spring Boot auto-configuration for the `MetadataStore`which can be used in various Spring Integration scenarios, like file polling, idempotent receiver, offset management etc.
4 | See Spring Integration "`https://docs.spring.io/spring-integration/docs/5.0.6.RELEASE/reference/html/system-management-chapter.html#metadata-store[Reference Manual]`" for more information.
5 |
6 | In addition to the standard Spring Boot configuration properties this module exposes a `MetadataStoreProperties` with the `metadata.store` prefix.
7 |
8 | To auto-configure particular `MetadataStore` you just need to bring respective dependencies into the target app starter:
9 |
10 | ==== Redis
11 |
12 | The `RedisMetadataStore` requires regular Spring Boot auto-configuration for https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-redis[Spring Data Redis] and minimal set of dependencies is like this:
13 |
14 | [source,xml]
15 | ----
16 |
17 | org.springframework.integration
18 | spring-integration-redis
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-data-redis
23 |
24 | ----
25 |
26 | Additional configuration property for `RedisMetadataStore` is:
27 |
28 | $$metadata.store.redis.key$$:: $$Redis key for metadata.$$ *($$String$$, default: `$$MetaData$$`)*
29 |
30 | ==== MongoDb
31 |
32 | The `MongoDbMetadataStore` requires regular Spring Boot auto-configuration for https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-mongodb[Spring Data MongoDB] and minimal set of dependencies is like this:
33 |
34 | [source,xml]
35 | ----
36 |
37 | org.springframework.integration
38 | spring-integration-mongodb
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-starter-data-mongodb
43 |
44 | ----
45 |
46 | Additional configuration property for `MongoDbMetadataStore` is:
47 |
48 | $$metadata.store.mongo-db.collection$$:: $$MongoDB collection name for metadata.$$ *($$String$$, default: `$$metadataStore$$`)*
49 |
50 | ==== Pivotal Gemfire / Apache Geode
51 |
52 | The `GemfireMetadataStore` requires these dependencies for auto-configuration:
53 |
54 | [source,xml]
55 | ----
56 |
57 | org.springframework.integration
58 | spring-integration-gemfire
59 |
60 | ----
61 |
62 | or when your environment is based on the Open Source https://geode.apache.org/[Apache Geode]:
63 |
64 | [source,xml]
65 | ----
66 |
67 | org.springframework.integration
68 | spring-integration-gemfire
69 |
70 |
71 | org.springframework.data
72 | spring-data-gemfire
73 |
74 |
75 |
76 |
77 | org.springframework.data
78 | spring-data-geode
79 |
80 | ----
81 |
82 | You also can consider to use https://github.com/spring-projects/spring-boot-data-geode[Spring Boot Data Geode] instead for automatic dependency management and proper Spring Boot auto-configuration for Pivotal Gemfire/Apache Geode.
83 |
84 | Additional configuration property for `GemfireMetadataStore` is:
85 |
86 | $$metadata.store.gemfire.region$$:: $$Gemfire region name for metadata.$$ *($$String$$, default: `$$MetaData$$`)*
87 |
88 | In addition, for the `GemfireMetadataStore`, a `MetadataStoreListener` bean can be configured in the application context to react to the `MetadataStore` events.
89 |
90 | A default auto-configured `ClientRegionFactoryBean`, based on the auto-configured `GemFireCache`, bean can be overridden in the target application.
91 |
92 | ==== Hazelcast
93 |
94 | The `HazelcastMetadataStore` requires regular Spring Boot auto-configuration for https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-caching-provider-hazelcast[Hazelcast] and minimal set of dependencies is like this:
95 |
96 | [source,xml]
97 | ----
98 |
99 | org.springframework.integration
100 | spring-integration-hazelcast
101 |
102 | ----
103 |
104 | There are no additional configuration properties for the `HazelcastMetadataStore`, however a `MetadataStoreListener` bean can be configured in the application context to react to the `MetadataStore` events.
105 |
106 | ==== Zookeeper
107 |
108 | The `ZookeeperMetadataStore` requires this dependency for auto-configuration:
109 |
110 | [source,xml]
111 | ----
112 |
113 | org.springframework.integration
114 | spring-integration-zookeeper
115 |
116 | ----
117 |
118 | The configuration properties for `ZookeeperMetadataStore` are:
119 |
120 | $$metadata.store.zookeeper.connect-string$$:: $$Zookeeper connect string in form HOST:PORT.$$ *($$String$$, default: `$$127.0.0.1:2181$$`)*
121 | $$metadata.store.zookeeper.retry-interval$$:: $$Retry interval for Zookeeper operations in milliseconds.$$ *($$int$$, default: `$$1000$$`)*
122 | $$metadata.store.zookeeper.encoding$$:: $$Encoding to use when storing data in Zookeeper.$$ *($$Charset$$, default: `$$UTF-8$$`)*
123 | $$metadata.store.zookeeper.root$$:: $$Root node - store entries are children of this node.$$ *($$String$$, default: `$$/SpringIntegration-MetadataStore$$`)*
124 |
125 | In addition, for the `ZookeeperMetadataStore`, a `MetadataStoreListener` bean can be configured in the application context to react to the `MetadataStore` events.
126 | Also a `CuratorFramework` bean can be provided to override a default auto-configured one.
127 |
128 | ==== AWS DymanoDb
129 |
130 | The `DynamoDbMetadataStore` requires regular Spring Cloud AWS auto-configuration for https://cloud.spring.io/spring-cloud-static/spring-cloud-aws/2.0.0.RELEASE/single/spring-cloud-aws.html#_spring_boot_auto_configuration[Spring Boot] and minimal set of dependencies is like this:
131 |
132 | [source,xml]
133 | ----
134 |
135 | org.springframework.integration
136 | spring-integration-aws
137 |
138 |
139 | com.amazonaws
140 | aws-java-sdk-dynamodb
141 |
142 | ----
143 |
144 | Additional configuration properties for `DynamoDbMetadataStore` are:
145 |
146 | $$metadata.store.dynamo-db.table:: $$Table name for metadata.$$ *($$String$$, default: `$$SpringIntegrationMetadataStore$$`)*
147 | $$metadata.store.dynamo-db.read-capacity:: $$Read capacity on the table.$$ *($$long$$, default: `$$1$$`)*
148 | $$metadata.store.dynamo-db.write-capacity:: $$Write capacity on the table.$$ *($$long$$, default: `$$1$$`)*
149 | $$metadata.store.dynamo-db.create-delay:: $$Delay between create table retries.$$ *($$int$$, default: `$$1$$`)*
150 | $$metadata.store.dynamo-db.create-retries:: $$Retry number for create table request.$$ *($$int$$, default: `$$25$$`)*
151 | $$metadata.store.dynamo-db.time-to-live:: $$TTL for table entries.$$ *($$Integer$$, default: `$$$$`)*
152 |
153 | A default, auto-configured `AmazonDynamoDBAsync` bean can be overridden in the target application.
154 |
155 | ==== JDBC
156 |
157 | The `JdbcMetadataStore` requires regular Spring Boot auto-configuration for https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-sql[JDBC DataSource] and minimal set of dependencies is like this:
158 |
159 | [source,xml]
160 | ----
161 |
162 | org.springframework.integration
163 | spring-integration-jdbc
164 |
165 |
166 | org.springframework.boot
167 | spring-boot-starter-jdbc
168 |
169 | ----
170 |
171 | Plus vendor-specific JDBC driver artifact(s).
172 |
173 | Additional configuration properties for `JdbcMetadataStore` are:
174 |
175 | $$metadata.store.jdbc.table-prefix:: $$Prefix for the custom table name.$$ *($$String$$, default: `$$INT_$$`)*
176 | $$metadata.store.jdbc.region:: $$Unique grouping identifier for messages persisted with this store.$$ *($$String$$, default: `$$DEFAULT$$`)*
177 |
178 |
179 |
180 | When no any of those technologies dependencies are preset, an in-memory `SimpleMetadataStore` is auto-configured.
181 | The target application can also provide its own `MetadataStore` bean to override any auto-configuration hooks.
182 |
--------------------------------------------------------------------------------
/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # https://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | #
58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look
59 | # for the new JDKs provided by Oracle.
60 | #
61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
62 | #
63 | # Apple JDKs
64 | #
65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
66 | fi
67 |
68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
69 | #
70 | # Apple JDKs
71 | #
72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
73 | fi
74 |
75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
76 | #
77 | # Oracle JDKs
78 | #
79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
80 | fi
81 |
82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
83 | #
84 | # Apple JDKs
85 | #
86 | export JAVA_HOME=`/usr/libexec/java_home`
87 | fi
88 | ;;
89 | esac
90 |
91 | if [ -z "$JAVA_HOME" ] ; then
92 | if [ -r /etc/gentoo-release ] ; then
93 | JAVA_HOME=`java-config --jre-home`
94 | fi
95 | fi
96 |
97 | if [ -z "$M2_HOME" ] ; then
98 | ## resolve links - $0 may be a link to maven's home
99 | PRG="$0"
100 |
101 | # need this for relative symlinks
102 | while [ -h "$PRG" ] ; do
103 | ls=`ls -ld "$PRG"`
104 | link=`expr "$ls" : '.*-> \(.*\)$'`
105 | if expr "$link" : '/.*' > /dev/null; then
106 | PRG="$link"
107 | else
108 | PRG="`dirname "$PRG"`/$link"
109 | fi
110 | done
111 |
112 | saveddir=`pwd`
113 |
114 | M2_HOME=`dirname "$PRG"`/..
115 |
116 | # make it fully qualified
117 | M2_HOME=`cd "$M2_HOME" && pwd`
118 |
119 | cd "$saveddir"
120 | # echo Using m2 at $M2_HOME
121 | fi
122 |
123 | # For Cygwin, ensure paths are in UNIX format before anything is touched
124 | if $cygwin ; then
125 | [ -n "$M2_HOME" ] &&
126 | M2_HOME=`cygpath --unix "$M2_HOME"`
127 | [ -n "$JAVA_HOME" ] &&
128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
129 | [ -n "$CLASSPATH" ] &&
130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
131 | fi
132 |
133 | # For Migwn, ensure paths are in UNIX format before anything is touched
134 | if $mingw ; then
135 | [ -n "$M2_HOME" ] &&
136 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
137 | [ -n "$JAVA_HOME" ] &&
138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
139 | # TODO classpath?
140 | fi
141 |
142 | if [ -z "$JAVA_HOME" ]; then
143 | javaExecutable="`which javac`"
144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
145 | # readlink(1) is not available as standard on Solaris 10.
146 | readLink=`which readlink`
147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
148 | if $darwin ; then
149 | javaHome="`dirname \"$javaExecutable\"`"
150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
151 | else
152 | javaExecutable="`readlink -f \"$javaExecutable\"`"
153 | fi
154 | javaHome="`dirname \"$javaExecutable\"`"
155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
156 | JAVA_HOME="$javaHome"
157 | export JAVA_HOME
158 | fi
159 | fi
160 | fi
161 |
162 | if [ -z "$JAVACMD" ] ; then
163 | if [ -n "$JAVA_HOME" ] ; then
164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
165 | # IBM's JDK on AIX uses strange locations for the executables
166 | JAVACMD="$JAVA_HOME/jre/sh/java"
167 | else
168 | JAVACMD="$JAVA_HOME/bin/java"
169 | fi
170 | else
171 | JAVACMD="`which java`"
172 | fi
173 | fi
174 |
175 | if [ ! -x "$JAVACMD" ] ; then
176 | echo "Error: JAVA_HOME is not defined correctly." >&2
177 | echo " We cannot execute $JAVACMD" >&2
178 | exit 1
179 | fi
180 |
181 | if [ -z "$JAVA_HOME" ] ; then
182 | echo "Warning: JAVA_HOME environment variable is not set."
183 | fi
184 |
185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
186 |
187 | # For Cygwin, switch paths to Windows format before running java
188 | if $cygwin; then
189 | [ -n "$M2_HOME" ] &&
190 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
191 | [ -n "$JAVA_HOME" ] &&
192 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
193 | [ -n "$CLASSPATH" ] &&
194 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
195 | fi
196 |
197 | # traverses directory structure from process work directory to filesystem root
198 | # first directory with .mvn subdirectory is considered project base directory
199 | find_maven_basedir() {
200 | local basedir=$(pwd)
201 | local wdir=$(pwd)
202 | while [ "$wdir" != '/' ] ; do
203 | if [ -d "$wdir"/.mvn ] ; then
204 | basedir=$wdir
205 | break
206 | fi
207 | wdir=$(cd "$wdir/.."; pwd)
208 | done
209 | echo "${basedir}"
210 | }
211 |
212 | # concatenates all lines of a file
213 | concat_lines() {
214 | if [ -f "$1" ]; then
215 | echo "$(tr -s '\n' ' ' < "$1")"
216 | fi
217 | }
218 |
219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
221 |
222 | # Provide a "standardized" way to retrieve the CLI args that will
223 | # work with both Windows and non-Windows executions.
224 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
225 | export MAVEN_CMD_LINE_ARGS
226 |
227 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
228 |
229 | echo "Running version check"
230 | VERSION=$( sed '\!//' -e 's!.*$!!' )
231 | echo "The found version is [${VERSION}]"
232 |
233 | if echo $VERSION | egrep -q 'M|RC'; then
234 | echo Activating \"milestone\" profile for version=\"$VERSION\"
235 | echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone"
236 | else
237 | echo Deactivating \"milestone\" profile for version=\"$VERSION\"
238 | echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//')
239 | fi
240 |
241 | if echo $VERSION | egrep -q 'RELEASE'; then
242 | echo Activating \"central\" profile for version=\"$VERSION\"
243 | echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pcentral"
244 | else
245 | echo Deactivating \"central\" profile for version=\"$VERSION\"
246 | echo $MAVEN_ARGS | grep -q central && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pcentral//')
247 | fi
248 |
249 | exec "$JAVACMD" \
250 | $MAVEN_OPTS \
251 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
252 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
253 | ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@"
254 |
--------------------------------------------------------------------------------