Skip to content

Commit

Permalink
Added Support for M1 Mac (#113)
Browse files Browse the repository at this point in the history
* Added Support for M1 Mac

* Addressed code review comments

* Renamed variable to avoid confusion
  • Loading branch information
henryhchchc authored Dec 10, 2021
1 parent 8d2a031 commit 61329d2
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/main/java/org/openjfx/gradle/JavaFXPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@

public enum JavaFXPlatform {

LINUX("linux", "linux"),
WINDOWS("win", "windows"),
OSX("mac", "osx");
LINUX("linux", "linux-x86_64"),
LINUX_AARCH64("linux-aarch64", "linux-aarch_64"),
WINDOWS("win", "windows-x86_64"),
OSX("mac", "osx-x86_64"),
OSX_AARCH64("mac-aarch64", "osx-aarch_64");

private String classifier;
private String osDetectorId;
private final String classifier;
private final String osDetectorClassifier;

JavaFXPlatform( String classifier, String osDetectorId ) {
JavaFXPlatform( String classifier, String osDetectorClassifier ) {
this.classifier = classifier;
this.osDetectorId = osDetectorId;
this.osDetectorClassifier = osDetectorClassifier;
}

public String getClassifier() {
Expand All @@ -56,23 +58,23 @@ public String getClassifier() {

public static JavaFXPlatform detect(Project project) {

String os = project.getExtensions().getByType(OsDetector.class).getOs();
final String osClassifier = project.getExtensions().getByType(OsDetector.class).getClassifier();

for ( JavaFXPlatform platform: values()) {
if ( platform.osDetectorId.equals(os)) {
if ( platform.osDetectorClassifier.equals(osClassifier)) {
return platform;
}
}

String supportedPlatforms = Arrays.stream(values())
.map(p->p.osDetectorId)
.map(p->p.osDetectorClassifier)
.collect(Collectors.joining("', '", "'", "'"));

throw new GradleException(
String.format(
"Unsupported JavaFX platform found: '%s'! " +
"This plugin is designed to work on supported platforms only." +
"Current supported platforms are %s.", os, supportedPlatforms )
"Current supported platforms are %s.", osClassifier, supportedPlatforms )
);

}
Expand Down

0 comments on commit 61329d2

Please sign in to comment.