Skip to content

Commit

Permalink
* Fix PlatformPlugin evaluating javacppPlatform too early (issue #8
Browse files Browse the repository at this point in the history
)
  • Loading branch information
saudet committed Nov 8, 2020
1 parent 3bfc84a commit 8b97e37
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Fix `PlatformPlugin` evaluating `javacppPlatform` too early ([issue #8](https://github.com/bytedeco/gradle-javacpp/issues/8))
* Honor the `skip` property in `BuildTask` ([pull #7](https://github.com/bytedeco/gradle-javacpp/issues/7))
* Add `BuildExtension` helper for `maven-publish` and update zlib sample project
* Add builds for Android to zlib sample project ([issue #5](https://github.com/bytedeco/gradle-javacpp/issues/5))
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/bytedeco/gradle/javacpp/PlatformPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ public class PlatformPlugin implements Plugin<Project> {
project.getExtensions().getExtraProperties().set("javacppPlatform", Loader.Detector.getPlatform());
}

project.getDependencies().getComponents().all(PlatformRule.class, rule -> {
rule.setParams(project.findProperty("javacppPlatform"));
project.afterEvaluate(p -> {
p.getDependencies().getComponents().all(PlatformRule.class, rule -> {
rule.setParams(p.findProperty("javacppPlatform"));
});
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class BuildPluginTest {
project.getPlugins().apply("org.bytedeco.gradle-javacpp-build");

assertEquals(Loader.Detector.getPlatform(), project.findProperty("javacppPlatform"));
assertTrue(project.getExtensions().findByName("javacppBuild") instanceof BuildExtension);
assertNotNull(project.getTasks().findByName("javacppBuildCommand"));
assertNotNull(project.getTasks().findByName("javacppCompileJava"));
assertNotNull(project.getTasks().findByName("javacppBuildParser"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.gradle.api.Project;
import org.gradle.api.artifacts.dsl.ComponentMetadataHandler;
import org.gradle.api.internal.artifacts.dsl.DefaultComponentMetadataHandler;
import org.gradle.api.internal.project.DefaultProject;
import org.junit.Test;
import static org.junit.Assert.*;

Expand All @@ -38,6 +39,10 @@ public class PlatformPluginTest {
project.getPlugins().apply("org.bytedeco.gradle-javacpp-platform");

assertEquals(Loader.Detector.getPlatform(), project.findProperty("javacppPlatform"));
project.getExtensions().getExtraProperties().set("javacppPlatform", "linux-armhf,linux-arm64");
((DefaultProject)project).evaluate();
assertEquals("linux-armhf,linux-arm64", project.findProperty("javacppPlatform"));

ComponentMetadataHandler h = project.getDependencies().getComponents();
Field f = DefaultComponentMetadataHandler.class.getDeclaredField("metadataRuleContainer");
f.setAccessible(true);
Expand Down

0 comments on commit 8b97e37

Please sign in to comment.