This message was deleted.
# general
s
This message was deleted.
c
Do you own that iceberg-data project?
I'm guessing too much here, but you want to use in your tests some code from another library tests, then...what you probably want is in that iceberg-data library to publish TestFixtures (with the factories or utilities you need)
d
Do you own that iceberg-data project?
Nope.
This project provide some compatibility test, so I'd like to inherit it. Something similar to this:
TestPartitioningWriters
is in
iceberg-data-0.13.0-tests.jar
, i guest
Bingo 😉
Copy code
testImplementation("org.apache.iceberg:iceberg-data:$icebergVersion:tests")
v
That's the poormans solution, yes. 🙂 As they publish Gradle Module Metadata, the proper solution is to ask them to publish a variant for the tests, so that you can depend on that feature vairant using for example
Copy code
testImplementation("org.apache.iceberg:iceberg-data:0.13.0") {
    capabilities {
        requireCapability("org.apache.iceberg:iceberg-data-tests")
    }
}
The idiomatic work-around is to use a component metadata rule to add that variant ad-hoc like
Copy code
dependencies {
    components {
        withModule("org.apache.iceberg:iceberg-data") {
            addVariant("tests") {
                withCapabilities {
                    removeCapability(id.group, id.name)
                    addCapability(id.group, "${id.name}-tests", id.version)
                }
                withFiles {
                    addFile("${id.name}-${id.version}-tests.jar")
                }
            }
        }
    }
    testImplementation("org.apache.iceberg:iceberg-data:0.13.0") {
        capabilities {
            requireCapability("org.apache.iceberg:iceberg-data-tests")
        }
    }
}
Or with the component metadata rule in your settings script, or even with the logic in its own class.
1
m
actually if they used the standard Gradle test fixtures plugin, all you'd have to do is:
Copy code
testImplementation(testFixtures("org.apache.iceberg:iceberg-data:0.13.0"))
1
v
I looked into the module file before I wrote and there is no variant for that jar. That's why I said that the proper fix is for them to publish a variant for it. 😉
m
I was answering about your dependency notation. If you use the standard test-fixtures variant, all you have to do is use the
testFixtures
notation, not the longer capabilities one
v
You mean if my added capability would be the one the test fixtures plugin used and / or if the iceberg project used the test testFixtures plugin to publish the variant and not create a new variant, yeah, that's true of course. So my code snippets then were
Copy code
testImplementation(testFixtures("org.apache.iceberg:iceberg-data:0.13.0"))
and
Copy code
dependencies {
    components {
        withModule("org.apache.iceberg:iceberg-data") {
            addVariant("testFixtures") {
                withCapabilities {
                    removeCapability(id.group, id.name)
                    addCapability(id.group, "${id.name}-test-fixtures", id.version)
                }
                withFiles {
                    addFile("${id.name}-${id.version}-tests.jar")
                }
            }
        }
    }
    testImplementation(testFixtures("org.apache.iceberg:iceberg-data:0.13.0"))
}
m
yes
❤️ 1