Contributing the [Gradle plugin](https://github.com/ben-manes/gradle-jooq-plugin) required, - Updating to the package names - Adding to the Maven build. The Gradle plugin dependencies piggyback on Flyway's repository, as Gradle does not officially publish the dependencies for building plugins in another build tool. - Assigning copyright This contribution is not tested due to a broader build failure in `FlashbackTable`. Note that this plugin took a simple and fast approach by leveraging Groovy's XML markeup syntax. This provided a concise extension, at the cost of flexibility to customize the plugin in multiple build scripts (e.g. subproject adding data type converters). A richer plugin should be created, but exceeded the scope of what was needed at the time of development.
51 lines
1.5 KiB
Java
51 lines
1.5 KiB
Java
/*
|
|
* Copyright 2013 Ben Manes. All Rights Reserved.
|
|
*
|
|
* 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 example;
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
import com.google.inject.AbstractModule;
|
|
import com.google.inject.Provides;
|
|
import com.googlecode.flyway.core.Flyway;
|
|
import org.h2.jdbcx.JdbcDataSource;
|
|
|
|
/**
|
|
* A module that configures the H2 data source.
|
|
*
|
|
* @author Ben Manes (ben.manes@gmail.com)
|
|
*/
|
|
public class H2Module extends AbstractModule {
|
|
private static final String URL = "jdbc:h2:mem:test_%d;DB_CLOSE_DELAY=-1";
|
|
private static final AtomicInteger counter = new AtomicInteger();
|
|
|
|
@Override
|
|
protected void configure() {}
|
|
|
|
@Provides
|
|
DataSource providesDataSource() {
|
|
JdbcDataSource dataSource = new JdbcDataSource();
|
|
dataSource.setURL(String.format(URL, counter.incrementAndGet()));
|
|
|
|
Flyway flyway = new Flyway();
|
|
flyway.setDataSource(dataSource);
|
|
flyway.migrate();
|
|
|
|
return dataSource;
|
|
}
|
|
}
|