Hi,
Yeah, understanding the source sets (or whatever the concept is properly
called, not sure I have the right naming myself) can be challenging. This can
be a bit of help: https://www.baeldung.com/gradle-source-sets
Our code for starting the container is pretty much like this:
DockerImageName imageName = DockerImageName.parse(
"timescale/timescaledb:2.14.2-pg13-oss" ).asCompatibleSubstituteFor( "postgres"
);
try ( JdbcDatabaseContainer<?> container = new PostgreSQLContainer<>(
imageName ) ) {
container.start();
// Apply migrations, run jOOQ codegen
}
Best regards,
Per
________________________________
From: [email protected] <[email protected]> on behalf of
Pasha Finkelshtein <[email protected]>
Sent: Thursday, February 22, 2024 15:03
To: jOOQ User Group <[email protected]>
Subject: Re: jOOQ+Liquibase+docker
Thank Per,
I'm absolutely not sure. My way of thinking was that both liquibase and jooq
need to have a running container. So it can't be neither jooqRuntime, nor
liquibaseRuntime, so it should be like "gradleRuntime", but there is no such
thing :)
How do you start the container?
Best,
Pasha
On Thursday 22 February 2024 at 12:36:29 UTC+1 Per Lundberg wrote:
Hi,
This seems to me like these dependencies are being added to the wrong classpath
somehow. Are you sure they should go to the buildscript dependencies?
Here's what we have, but as mentioned, we have our codegen running somewhat
differently (in a separate Gradle configuration/source set). Also note that we
are using jOOQ Pro in our case; IIRC the artifact names have to be edited if
you're using jOOQ Open Source (but the Gradle plugin probably takes care of the
jOOQ stuff anyway in your case).
dependencies {
// for running DB-based codegen in isolated Docker container
codegenImplementation(
"org.testcontainers:testcontainers:${testcontainersVersion}" ) {
exclude group: 'javax.xml.bind', module: 'jaxb-api'
}
codegenImplementation(
"org.testcontainers:postgresql:${testcontainersVersion}" ) {
exclude group: 'javax.xml.bind', module: 'jaxb-api'
}
codegenImplementation "org.postgresql:postgresql:${postgresqlJdbcVersion}"
codegenImplementation "${jooqGroupId}:jooq:${jooqVersion}"
codegenImplementation "${jooqGroupId}:jooq-codegen:${jooqVersion}"
}
Best regards,
Per
________________________________
From: [email protected] <[email protected]> on behalf of Pasha
Finkelshtein <[email protected]>
Sent: Thursday, February 22, 2024 12:08
To: jOOQ User Group <[email protected]>
Subject: Re: jOOQ+Liquibase+docker
This is what I have:
buildscript {
dependencies {
classpath("org.testcontainers:testcontainers:1.19.5")
classpath("org.testcontainers:postgresql:1.19.5")
}
repositories {
mavenCentral()
}
}
....
val testContainer =
org.testcontainers.containers.PostgreSQLContainer(DockerImageName.parse("paradedb/paradedb:latest").asCompatibleSubstituteFor("postgres"))
val startContainer by tasks.registering {
testContainer.start()
}
Hypothetically, it should to the trick - when I call gradlew startContainer or
when Liquibase's update tsk depends on it and I call update - it should spin up
the container and stop it only when the gradle is done.
Or, for example, if I will put jooqCodegen.finalizedBy(stopContainer) - the
same should happen. However, I got the following error in the very beginning:
Can't instantiate a strategy from
org.testcontainers.dockerclient.UnixSocketClientProviderStrategy
(ClassNotFoundException). This probably means that cached configuration refers
to a client provider class that is not available in this version of
Testcontainers. Other strategies will be tried instead.
Could not find a valid Docker environment. Please check configuration.
Attempted configurations were:
As no valid configuration was found, execution cannot continue.
I am not sure what is the issue here. Obviously, testcontainers work on my
machine; I have native Docker installed. I have a dependency on testcontainers
on my script's classpath. At this point I do not know what I am doing wrong :(
On Thursday 22 February 2024 at 10:31:34 UTC+1 Lukas Eder wrote:
Well, what did you try?
On Thu, Feb 22, 2024 at 10:19 AM Pasha Finkelshtein <[email protected]>
wrote:
This obviously SHOULD work, but it doesn't. And I was hoping to get a concrete
example to understand what I'm doing wrong.
It seems to me that test containers just don't work during the gradle build,
but maybe I'm wrong. And since nobody in the Testcontainers slack answer I
thought that maybe here somebody has a working example.
Sorry for bothering you
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jooq-user/c6de4831-14e6-4d64-b558-34b73b45a2ben%40googlegroups.com<https://groups.google.com/d/msgid/jooq-user/c6de4831-14e6-4d64-b558-34b73b45a2ben%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jooq-user/398d1de6-b1f0-42a4-887c-5e17c5bbf251n%40googlegroups.com<https://groups.google.com/d/msgid/jooq-user/398d1de6-b1f0-42a4-887c-5e17c5bbf251n%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jooq-user/VI0PR08MB10448C60863DA23CDCE8EF908EA562%40VI0PR08MB10448.eurprd08.prod.outlook.com.