Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added multiple configurations / changeable platform. + FREE BUILD #137

Merged
merged 9 commits into from
May 3, 2023
Prev Previous commit
Next Next commit
add multiple options to set platform
  • Loading branch information
abhinayagarwal committed May 3, 2023
commit 3f984e6794157845ceeb49289ee26b2dec851101
15 changes: 10 additions & 5 deletions src/main/java/org/openjfx/gradle/JavaFXOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ public JavaFXPlatform getPlatform() {
return platform;
}

/**
* Sets the target platform for the dependencies.
* @param platform platform classifier.
* Supported classifiers are linux, linux-aarch64, win/windows, osx/mac/macos or osx-aarch64/mac-aarch64/macos-aarch64.
*/
public void setPlatform(String platform) {
this.platform = JavaFXPlatform.fromString(platform);
updateJavaFXDependencies();
}

public String getVersion() {
return version;
}
Expand Down Expand Up @@ -181,9 +191,4 @@ private void clearJavaFXDependencies() {
}
}
}

public void setPlatform(JavaFXPlatform platform) {
this.platform = platform;
updateJavaFXDependencies();
}
}
30 changes: 25 additions & 5 deletions src/main/java/org/openjfx/gradle/JavaFXPlatform.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Gluon
* Copyright (c) 2018, 2023, Gluon
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -47,7 +47,7 @@ public enum JavaFXPlatform {
private final String classifier;
private final String osDetectorClassifier;

JavaFXPlatform( String classifier, String osDetectorClassifier ) {
JavaFXPlatform(String classifier, String osDetectorClassifier) {
this.classifier = classifier;
this.osDetectorClassifier = osDetectorClassifier;
}
Expand All @@ -60,14 +60,14 @@ public static JavaFXPlatform detect(Project project) {

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

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

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

throw new GradleException(
Expand All @@ -76,6 +76,26 @@ public static JavaFXPlatform detect(Project project) {
"This plugin is designed to work on supported platforms only." +
"Current supported platforms are %s.", osClassifier, supportedPlatforms )
);
}

public static JavaFXPlatform fromString(String platform) {
switch (platform) {
case "linux":
return JavaFXPlatform.LINUX;
case "linux-aarch64":
return JavaFXPlatform.LINUX_AARCH64;
case "win":
case "windows":
return JavaFXPlatform.WINDOWS;
case "osx":
case "mac":
case "macos":
return JavaFXPlatform.OSX;
case "osx-aarch64":
case "mac-aarch64":
case "macos-aarch64":
return JavaFXPlatform.OSX_AARCH64;
}
return valueOf(platform);
}
}