Skip to content

Commit

Permalink
wait until java plugin applied (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
esword authored Nov 27, 2024
1 parent f9bbd92 commit 7cc9b09
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-6.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: fix
fix:
description: wait until java plugin applied
links:
- https://github.com/palantir/gradle-plugin-testing/pull/6
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ public class PluginTestingPlugin implements Plugin<Project> {
*/
@Override
public void apply(Project project) {
PluginTestingExtension testUtilsExt =
project.getExtensions().create(PluginTestingExtension.EXTENSION_NAME, PluginTestingExtension.class);
project.getExtensions().create(PluginTestingExtension.EXTENSION_NAME, PluginTestingExtension.class);
// need the SourceSetContainer extension so need to wait until java plugin is applied
project.getPluginManager().withPlugin("java", _unused -> {
doApply(project);
});
}

private static void doApply(Project project) {
PluginTestingExtension testUtilsExt = project.getExtensions().getByType(PluginTestingExtension.class);

addTestDependency(project);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ class PluginTestingPluginIntegrationSpec extends IntegrationSpec {
!result.success
}

def 'works when applied before other plugins'() {
given:
buildFile.text = """
apply plugin: 'com.palantir.gradle-plugin-testing'
""".stripIndent(true) + buildFile.text

when:
def result = runTasks('test')

then:
result.success
}

def 'resolve dependencies'() {
given:
applyTestUtilsPlugin()
Expand Down

0 comments on commit 7cc9b09

Please sign in to comment.