Single Project

And now we arrive at the end, a single concise project.

Signed-off-by: Ben Hale <bhale@vmware.com>
This commit is contained in:
Ben Hale
2020-05-09 09:03:58 -07:00
parent 04eed55e6a
commit ff878c8c95
60 changed files with 328 additions and 868 deletions

117
.mvn/wrapper/MavenWrapperDownloader.java vendored Normal file
View File

@@ -0,0 +1,117 @@
/*
* Copyright 2007-present 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.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.5";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}

Binary file not shown.

View File

@@ -1 +1,2 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar

View File

@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>cnb-bindings-parent</artifactId>
<version>0.0.1.BUILD-SNAPSHOT</version>
</parent>
<artifactId>cnb-bindings-boot</artifactId>
<name>CNB Bindings Spring Boot</name>
<description>Java CNB Spring Boot Support</description>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>cnb-bindings-jdbc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -1,45 +0,0 @@
/*
* Copyright 2019 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.cloud.cnb.boot;
import java.util.Map;
import org.springframework.cloud.cnb.Binding;
import org.springframework.cloud.cnb.jdbc.JdbcBinding;
public class DataSourceCnbBindingProcessor implements CnbBindingProcessor {
@Override
public boolean accept(Binding binding) {
return JdbcBinding.isJDCBBinding(binding);
}
@Override
public void process(Binding binding, Map<String, Object> properties) {
JdbcBinding jdbcBinding = new JdbcBinding(binding);
properties.put("spring.datasource.url", jdbcBinding.getJdbcUrl());
properties.put("spring.datasource.username", jdbcBinding.getUsername());
properties.put("spring.datasource.password", jdbcBinding.getPassword());
properties.put("spring.datasource.driver-class-name", jdbcBinding.getDriverClassName());
}
@Override
public CnbBindingProcessorProperties getProperties() {
return CnbBindingProcessorProperties.builder()
.propertyPrefixes("spring.datasource")
.build();
}
}

View File

@@ -1,11 +0,0 @@
# Environment Post Processors
org.springframework.boot.env.EnvironmentPostProcessor=\
org.springframework.cloud.cnb.boot.CnbBindingsPostProcessor
# Also register as a ApplicationListener to log what occurred in the post processing step
org.springframework.context.ApplicationListener=\
org.springframework.cloud.cnb.boot.CnbBindingsPostProcessor
# CnbBindingsPostProcessor delegates to these CnbBindingsProcessors for each CF service
org.springframework.cloud.cnb.boot.CnbBindingProcessor=\
org.springframework.cloud.cnb.boot.DataSourceCnbBindingProcessor

View File

@@ -1,75 +0,0 @@
/*
* Copyright 2019 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.cloud.cnb.boot;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.springframework.cloud.cnb.Binding;
import static org.assertj.core.api.Assertions.assertThat;
public class DataSourceCnbBindingProcessorTests {
@Test
public void acceptIfJdbcTest() {
DataSourceCnbBindingProcessor bindingProcessor = new DataSourceCnbBindingProcessor();
Map<String, String> bindingMetadata = new HashMap<String, String>();
bindingMetadata.put("kind", "mysql");
Binding binding = new Binding(bindingMetadata, new HashMap<String, String>());
assertThat(bindingProcessor.accept(binding)).isTrue();
}
@Test
public void rejectIfNotJdbcTest() {
DataSourceCnbBindingProcessor bindingProcessor = new DataSourceCnbBindingProcessor();
Map<String, String> bindingMetadata = new HashMap<String, String>();
bindingMetadata.put("kind", "redis");
Binding binding = new Binding(bindingMetadata, new HashMap<String, String>());
assertThat(bindingProcessor.accept(binding)).isFalse();
}
@Test
public void processDataSourcePropertiesTest() {
DataSourceCnbBindingProcessor bindingProcessor = new DataSourceCnbBindingProcessor();
Map<String, String> bindingMetadata = new HashMap<String, String>();
bindingMetadata.put("kind", "test-kind");
Map<String,String> bindingSecret = new HashMap<String,String>();
bindingSecret.put("hostname", "10.0.4.35");
bindingSecret.put("port", "3306");
bindingSecret.put("db", "some-db");
bindingSecret.put("username", "some-username");
bindingSecret.put("password", "some-password");
Binding binding = new Binding(bindingMetadata, bindingSecret);
Map<String,Object> properties = new HashMap<String,Object>();
bindingProcessor.process(binding, properties);
assertThat(properties.get("spring.datasource.url")).isEqualTo("jdbc:testscheme://10.0.4.35:3306/some-db?user=some-username&password=some-password");
assertThat(properties.get("spring.datasource.username")).isEqualTo("some-username");
assertThat(properties.get("spring.datasource.password")).isEqualTo("some-password");
assertThat(properties.get("spring.datasource.driver-class-name")).isEqualTo("test.kind.fake.jdbc.Driver");
}
@Test
public void processorPropertiesTest() {
DataSourceCnbBindingProcessor bindingProcessor = new DataSourceCnbBindingProcessor();
CnbBindingProcessorProperties processorProperties = bindingProcessor.getProperties();
}
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright 2019 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.cloud.cnb.boot.test;
import java.util.HashMap;
import java.util.Map;
import mockit.MockUp;
import org.springframework.cloud.cnb.Bindings;
/**
* @author Emily Casey
**/
public class EnvMock {
private MockUp<?> mockUp;
public EnvMock(String cnbBindingsPath) {
Map<String, String> env = System.getenv();
this.mockUp = new MockUp<System>() {
@mockit.Mock
public String getenv(String name) {
if (name.equalsIgnoreCase(Bindings.CNB_BINDINGS)) {
return cnbBindingsPath;
}
return env.get(name);
}
@mockit.Mock
public Map getenv() {
Map<String, String> finalMap = new HashMap<>();
finalMap.putAll(env);
finalMap.put("CNB_BINDINGS", cnbBindingsPath);
return finalMap;
}
};
}
}

View File

@@ -1,40 +0,0 @@
/*
* Copyright 2019 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.cloud.cnb.boot.test;
import org.springframework.cloud.cnb.Binding;
import org.springframework.cloud.cnb.jdbc.JdbcKind;
public class TestJdbcKind implements JdbcKind {
@Override
public boolean forBinding(Binding binding) {
if (binding.getKind().equals("test-kind")) {
return true;
}
return false;
}
@Override
public String getScheme() {
return "testscheme";
}
@Override
public String getDriverClassName() {
return "test.kind.fake.jdbc.Driver";
}
}

View File

@@ -1 +0,0 @@
org.springframework.cloud.cnb.boot.test.TestJdbcKind

View File

@@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>cnb-bindings-parent</artifactId>
<version>0.0.1.BUILD-SNAPSHOT</version>
</parent>
<artifactId>cnb-bindings-jdbc</artifactId>
<name>CNB Bindings JDBC</name>
<description>CNB Bindings JDBC Support Library</description>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>cnb-bindings</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -1,88 +0,0 @@
/*
* Copyright 2019 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.cloud.cnb.jdbc;
import java.util.ServiceLoader;
import org.springframework.cloud.cnb.Binding;
import org.springframework.cloud.cnb.core.IllegalBindingException;
public class JdbcBinding {
private static final String JDBC_PREFIX = "jdbc:";
private final Binding binding;
private final JdbcKind kind;
public static boolean isJDCBBinding(Binding binding) {
ServiceLoader<JdbcKind> loader = ServiceLoader.load(JdbcKind.class);
for (JdbcKind kind : loader) {
if (kind.forBinding(binding)) {
return true;
}
}
return false;
}
public JdbcBinding(Binding binding) {
ServiceLoader<JdbcKind> loader = ServiceLoader.load(JdbcKind.class);
for (JdbcKind kind : loader) {
if (kind.forBinding(binding)) {
this.kind = kind;
this.binding = binding;
return;
}
}
throw new IllegalBindingException("no matching jdbc kind for binding");
}
public String getJdbcUrl() {
return String.format("%s%s://%s/%s%s", JDBC_PREFIX, kind.getScheme(),
buildHost(),
buildPath(),
buildQuery()
);
}
public String getDriverClassName() {
return kind.getDriverClassName();
}
private String buildHost() {
return String.format("%s:%s",
binding.getSecret().get("hostname"),
binding.getSecret().get("port")
);
}
private String buildPath() {
return binding.getSecret().get("db");
}
private String buildQuery() {
return String.format("?user=%s&password=%s",
binding.getSecret().get("username"),
binding.getSecret().get("password")
);
}
public String getUsername() {
return binding.getSecret().get("username");
}
public String getPassword() {
return binding.getSecret().get("password");
}
}

View File

@@ -1,24 +0,0 @@
/*
* Copyright 2019 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.cloud.cnb.jdbc;
import org.springframework.cloud.cnb.Binding;
public interface JdbcKind {
boolean forBinding(Binding binding);
String getScheme();
String getDriverClassName();
}

View File

@@ -1,5 +0,0 @@
org.springframework.cloud.cnb.jdbc.MysqlJdbcKind
org.springframework.cloud.cnb.jdbc.DB2JdbcKind
org.springframework.cloud.cnb.jdbc.OracleJdbcKind
org.springframework.cloud.cnb.jdbc.PostgresJdbcKind
org.springframework.cloud.cnb.jdbc.SqlServerJdbcKind

View File

@@ -1,100 +0,0 @@
/*
* Copyright 2019 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.cloud.cnb.jdbc;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.springframework.cloud.cnb.Binding;
import static org.assertj.core.api.Assertions.assertThat;
public class JdbcBindingTest {
@Test
public void testIsJdbcBinding_false() {
Binding notJdbcBinding = bindingWithKind("not-registered");
assertThat(JdbcBinding.isJDCBBinding(notJdbcBinding)).isFalse();
}
@Test
public void testJdbcBinding_mysql() {
Binding mysqlBinding = bindingWithKind("mysql");
assertThat(JdbcBinding.isJDCBBinding(mysqlBinding)).isTrue();
JdbcBinding jdbcBinding = new JdbcBinding(mysqlBinding);
assertThat(jdbcBinding.getJdbcUrl()).
isEqualTo("jdbc:mysql://10.0.4.35:3306/some-db?user=some-username&password=some-password");
}
@Test
public void testJdbcBinding_oracle() {
Binding oracleBinding = bindingWithKind("oracle");
assertThat(JdbcBinding.isJDCBBinding(oracleBinding)).isTrue();
JdbcBinding jdbcBinding = new JdbcBinding(oracleBinding);
assertThat(jdbcBinding.getJdbcUrl())
.isEqualTo("jdbc:oracle://10.0.4.35:3306/some-db?user=some-username&password=some-password");
assertThat(jdbcBinding.getDriverClassName()).
isEqualTo("oracle.jdbc.OracleDriver");
}
@Test
public void testJdbcBinding_postgres() {
Binding postgresBinding = bindingWithKind("postgres");
assertThat(JdbcBinding.isJDCBBinding(postgresBinding)).isTrue();
JdbcBinding jdbcBinding = new JdbcBinding(postgresBinding);
assertThat(jdbcBinding.getJdbcUrl())
.isEqualTo("jdbc:postgres://10.0.4.35:3306/some-db?user=some-username&password=some-password");
assertThat(jdbcBinding.getDriverClassName()).
isEqualTo("org.postgresql.Driver");
}
@Test
public void testJdbcBinding_postgresql() {
Binding postgresBinding = bindingWithKind("postgresql");
assertThat(JdbcBinding.isJDCBBinding(postgresBinding)).isTrue();
JdbcBinding jdbcBinding = new JdbcBinding(postgresBinding);
assertThat(jdbcBinding.getJdbcUrl())
.isEqualTo("jdbc:postgres://10.0.4.35:3306/some-db?user=some-username&password=some-password");
assertThat(jdbcBinding.getDriverClassName()).
isEqualTo("org.postgresql.Driver");
}
@Test
public void testJdbcBinding_sqlserver() {
Binding sqlserverBinding = bindingWithKind("sqlserver");
assertThat(JdbcBinding.isJDCBBinding(sqlserverBinding)).isTrue();
JdbcBinding jdbcBinding = new JdbcBinding(sqlserverBinding);
assertThat(jdbcBinding.getJdbcUrl())
.isEqualTo("jdbc:sqlserver://10.0.4.35:3306/some-db?user=some-username&password=some-password");
assertThat(jdbcBinding.getDriverClassName()).
isEqualTo("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
public Binding bindingWithKind(String kind) {
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("kind", kind);
Map<String, String> secret = new HashMap<String, String>();
secret.put("hostname", "10.0.4.35");
secret.put("port", "3306");
secret.put("db", "some-db");
secret.put("username", "some-username");
secret.put("password", "some-password");
return new Binding(metadata, secret);
}
}

View File

@@ -1,68 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2020 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.
-->
<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>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>cnb-bindings-parent</artifactId>
<version>0.0.1.BUILD-SNAPSHOT</version>
</parent>
<artifactId>cnb-bindings</artifactId>
<name>CNB Bindings</name>
<description>Java CNB Bindings Core Library</description>
<dependencies>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

91
mvnw vendored
View File

@@ -108,13 +108,12 @@ if $cygwin ; then
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Migwn, ensure paths are in UNIX format before anything is touched
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
@@ -200,8 +199,89 @@ if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
echo $MAVEN_PROJECTBASEDIR
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
@@ -216,6 +296,11 @@ if $cygwin; then
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \

43
mvnw.cmd vendored
View File

@@ -35,7 +35,9 @@
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
@@ -115,10 +117,47 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end

146
pom.xml
View File

@@ -5,13 +5,12 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.cloud</groupId>
<artifactId>cnb-bindings-parent</artifactId>
<artifactId>bindings</artifactId>
<version>0.0.1.BUILD-SNAPSHOT</version>
<packaging>pom</packaging>
<name>CNB Bindings Parent</name>
<name>Cloud Native Buildpacks Bindings</name>
<description>Java Library for Accessing CNB Bindings</description>
<url>https://github.com/spring-cloud-incubator/cnb-bindings</url>
<url>https://github.com/spring-cloud-incubator/bindings</url>
<licenses>
<license>
@@ -21,9 +20,9 @@
</licenses>
<scm>
<url>https://github.com/spring-cloud-incubator/cnb-bindings</url>
<connection>scm:git:git://github.com/spring-cloud-incubator/cnb-bindings.git</connection>
<developerConnection>scm:git:ssh://git@github.com/spring-cloud-incubator/cnb-bindings.git</developerConnection>
<url>https://github.com/spring-cloud-incubator/bindings</url>
<connection>scm:git:git://github.com/spring-cloud-incubator/bindings.git</connection>
<developerConnection>scm:git:ssh://git@github.com/spring-cloud-incubator/bindings.git</developerConnection>
</scm>
<properties>
@@ -42,19 +41,6 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<modules>
<module>cnb-bindings</module>
<module>cnb-bindings-jdbc</module>
<module>cnb-bindings-boot</module>
</modules>
<developers>
<developer>
<name>Emily Casey</name>
<id>ekcasey</id>
</developer>
</developers>
<dependencyManagement>
<dependencies>
<dependency>
@@ -64,56 +50,84 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>${jetbrains-annotations.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>${jetbrains-annotations.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<arg>-Werror</arg>
<arg>-Xlint:all</arg>
<arg>-Xlint:-options</arg>
<arg>-Xlint:-processing</arg>
<arg>-Xlint:-serial</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<runOrder>random</runOrder>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<arg>-Werror</arg>
<arg>-Xlint:all</arg>
<arg>-Xlint:-options</arg>
<arg>-Xlint:-processing</arg>
<arg>-Xlint:-serial</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<runOrder>random</runOrder>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,15 +0,0 @@
^\Q/*\E$
^\Q * Copyright \E(20\d\d\-)?20\d\d\Q the original author or authors.\E$
^\Q *\E$
^\Q * Licensed under the Apache License, Version 2.0 (the "License");\E$
^\Q * you may not use this file except in compliance with the License.\E$
^\Q * You may obtain a copy of the License at\E$
^\Q *\E$
^\Q * http://www.apache.org/licenses/LICENSE-2.0\E$
^\Q *\E$
^\Q * Unless required by applicable law or agreed to in writing, software\E$
^\Q * distributed under the License is distributed on an "AS IS" BASIS,\E$
^\Q * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\E$
^\Q * See the License for the specific language governing permissions and\E$
^\Q * limitations under the License.\E$
^\Q */\E$

View File

@@ -1,185 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<!-- Root Checks -->
<module name="RegexpHeader">
<property name="headerFile" value="src/checkstyle/checkstyle-header.txt"/>
<property name="fileExtensions" value="java"/>
</module>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
<module name="TreeWalker">
<property name="tabWidth" value="4"/>
<!--<module name="LineLength">-->
<!--<property name="max" value="120"/>-->
<!--</module>-->
<!-- Annotations -->
<module name="AnnotationUseStyle">
<property name="elementStyle" value="compact"/>
<property name="trailingArrayComma" value="never"/>
<property name="closingParens" value="never"/>
</module>
<module name="MissingOverride"/>
<module name="PackageAnnotation"/>
<module name="AnnotationLocation">
<property name="allowSamelineSingleParameterlessAnnotation"
value="false"/>
</module>
<!-- Block Checks -->
<module name="EmptyBlock">
<property name="option" value="text"/>
</module>
<!--
<module name="LeftCurly"/>
<module name="RightCurly">
<property name="option" value="alone"/>
</module>
<module name="NeedBraces"/>
<module name="AvoidNestedBlocks"/>
-->
<!-- tabs instead of spaces -->
<!--<module name="RegexpSinglelineJava">-->
<!--<property name="format" value="^\t* "/>-->
<!--<property name="message" value="Indent must use tab characters"/>-->
<!--<property name="ignoreComments" value="true"/>-->
<!--</module>-->
<!-- Class Design -->
<!--
<module name="FinalClass"/>
<module name="InterfaceIsType"/>
<module name="MutableException"/>
<module name="InnerTypeLast"/>
<module name="OneTopLevelClass"/>
-->
<!-- Coding -->
<!--
<module name="CovariantEquals"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="InnerAssignment"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="StringLiteralEquality"/>
<module name="NestedForDepth">
<property name="max" value="3"/>
</module>
<module name="NestedIfDepth">
<property name="max" value="3"/>
</module>
<module name="NestedTryDepth">
<property name="max" value="3"/>
</module>
<module name="MultipleVariableDeclarations"/>
<module name="RequireThis">
<property name="checkMethods" value="false"/>
</module>
<module name="OneStatementPerLine"/>
<module name="ExplicitInitialization"/>
<module name="ParameterAssignment"/>
-->
<!-- Imports -->
<module name="AvoidStarImport"/>
<module name="AvoidStaticImport">
<property name="excludes"
value="org.junit.Assert.*,org.mockito.Mockito.*,org.mockito.Matchers.*,org.mockito.ArgumentMatchers.*,
org.hamcrest.Matchers.*,
org.assertj.core.api.Assertions.*,org.hamcrest.CoreMatchers.*,org.hamcrest.core.Is.*,
org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*,
org.springframework.test.web.servlet.result.MockMvcResultMatchers.*,
org.springframework.test.web.servlet.result.MockMvcResultHandlers.*,
junit.framework.TestCase.*,
org.awaitility.Awaitility.*,
org.mockito.BDDMockito.*,
org.springframework.cloud.dataflow.server.single.security.SecurityTestUtils.*,
org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.*,
org.springframework.restdocs.operation.preprocess.Preprocessors.*,
org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*,
org.springframework.restdocs.payload.PayloadDocumentation.*,
org.springframework.restdocs.request.RequestDocumentation.*,
org.springframework.restdocs.headers.HeaderDocumentation.*,
org.springframework.restdocs.hypermedia.HypermediaDocumentation.*"/>
</module>
<!--<module name="FallThrough"/>-->
<module name="ImportOrder">
<property name="groups" value="java,/^javax?\./,*,org.springframework"/>
<property name="ordered" value="true"/>
<property name="separated" value="true"/>
<property name="option" value="bottom"/>
<property name="sortStaticImportsAlphabetically" value="true"/>
</module>
<!--<module name="IllegalImport">-->
<!--<property name="illegalPkgs" value="org.slf4j"/>-->
<!--</module>-->
<module name="RedundantImport"/>
<!--<module name="ReturnCount">-->
<!--<property name="max" value="0"/>-->
<!--<property name="tokens" value="CTOR_DEF"/>-->
<!--</module>-->
<!--<module name="ReturnCount">-->
<!--<property name="max" value="1"/>-->
<!--<property name="tokens" value="LAMBDA"/>-->
<!--</module>-->
<!--
<module name="ReturnCount">
<property name="max" value="3"/>
<property name="tokens" value="METHOD_DEF"/>
</module>
-->
<module name="UnusedImports"/>
<!-- Miscellaneous -->
<module name="CommentsIndentation"/>
<module name="UpperEll"/>
<module name="ArrayTypeStyle"/>
<module name="OuterTypeFilename"/>
<!-- Modifiers -->
<!--<module name="RedundantModifier"/>-->
<!-- Regexp -->
<!--<module name="RegexpSinglelineJava">-->
<!--<property name="format" value="^\t* +\t*\S"/>-->
<!--<property name="message"-->
<!--value="Line has leading space characters; indentation should be performed with tabs only."/>-->
<!--<property name="ignoreComments" value="true"/>-->
<!--</module>-->
<!--
<module name="Regexp">
<property name="format" value="[ \t]+$"/>
<property name="illegalPattern" value="true"/>
<property name="message" value="Trailing whitespace"/>
</module>
<module name="RegexpSinglelineJava">
<property name="maximum" value="0"/>
<property name="format" value="org\.junit\.Assert\.assert"/>
<property name="message"
value="Please use AssertJ imports."/>
<property name="ignoreComments" value="true"/>
</module>
-->
<!-- Whitespace -->
<!--
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter">
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS, ARRAY_DECLARATOR"/>
</module>
<module name="NoWhitespaceBefore"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
-->
</module>
</module>