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

Adjustments to let it run on macOS Ventura+ and build on Gradle 8+ #75

Merged
merged 5 commits into from
Feb 27, 2024

Conversation

pskowronek
Copy link
Contributor

Adjustments to let it run on macOS Ventura+ and build on Gradle 8+.

  • added gradlew
  • removed JavaAppLauncher and JavaAppLauncherStub
  • using universalJavaApplicationStub always (Apple and Oracle app styles use universalJavaApplicationStub)
  • adjusted plugin code to work with Gradle 8+
  • adjusted universalJavaApplicationStub to properly parse paths and version on Vantura+
  • contains fixes from Update to work with Gradle 7 #74

I know that author of this awesome plugin stopped maintaining this but maybe this PR will be approved.
Either it's going to be integrated in this repo, or I would need to publish it under a different id (or embed it into other projects code to use it).

@crotwell
Copy link
Owner

I have tried to test your PR using an old test case here, but after multiple attempts I keep hitting errors. They very likely may be due to my system or trying to publish the plugin locally to test, but get:

* What went wrong:
Could not determine the dependencies of task ':copyToResourcesJava'.
> Resolving dependency configuration 'default' is not allowed as it is defined as 'canBeResolved=false'.
  Instead, a resolvable ('canBeResolved=true') dependency configuration that extends 'default' should be resolved.

Have you been able to test successfully?

I am concerned that most of the code in this plugin is so old that it has subtle incompatibilities with newer ways of writing plugins for gradle. I am not opposed to upgrading and publishing it, but I am not developing java gui applications any more, so my ability to spend time on this is very limited.

If you would like to take it over and publish yourself under a new name, I would be happy to pass it on.

@pskowronek
Copy link
Contributor Author

I have tried to test your PR using an old test case here, but after multiple attempts I keep hitting errors. They very likely may be due to my system or trying to publish the plugin locally to test, but get:

Are you able to share that test case? (canBeResolved - as I have no clue so far).

If you would like to take it over and publish yourself under a new name, I would be happy to pass it on.

I will think about it :/

@crotwell
Copy link
Owner

So I tried with a new empty project. New directory, used gradle init and answered questions with:

Select type of project to generate:
  1: basic
  2: application
  3: library
  4: Gradle plugin
Enter selection (default: basic) [1..4] 2

Select implementation language:
  1: C++
  2: Groovy
  3: Java
  4: Kotlin
  5: Scala
  6: Swift
Enter selection (default: Java) [1..6] 3

Generate multiple subprojects for application? (default: no) [yes, no] 
Select build script DSL:
  1: Kotlin
  2: Groovy
Enter selection (default: Kotlin) [1..2] 1

Select test framework:
  1: JUnit 4
  2: TestNG
  3: Spock
  4: JUnit Jupiter
Enter selection (default: JUnit Jupiter) [1..4]  

Project name (default: testMacAppBundleRetry): 
Source package (default: testmacappbundleretry): 
Enter target version of Java (min. 7) (default: 17): 
Generate build using new APIs and behavior (some features may change in the next minor release)? (default: no) [yes, no] 

> Task :init
To learn more about Gradle by exploring our Samples at https://docs.gradle.org/8.5/samples/sample_building_java_applications.html

BUILD SUCCESSFUL in 46s

Then edited settings.gradle.kts to add:

pluginManagement {
    repositories {
        maven(url = "...path to.../local-plugin-repository")
        gradlePluginPortal()
    }
}

which I think is the correct way to test a locally published plugin.

Then edited app/build.gradle.kts to add:

id("edu.sc.seis.macAppBundle") version "2.3.1"

and then ran ./gradlew createApp but get:

 ./gradlew createApp

> Configure project :app
'Oracle' appStyle will be overridden with `universalJavaApplicationStub`!

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:copyToResourcesJava'.
> Resolving dependency configuration 'default' is not allowed as it is defined as 'canBeResolved=false'.
  Instead, a resolvable ('canBeResolved=true') dependency configuration that extends 'default' should be resolved.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 274ms

Doesn't really make a lot of sense to me. Any ideas?

@pskowronek
Copy link
Contributor Author

I will try to take a look (gradle, their docs, their hermetic error reporting and the way they change things always give me a headache :) )

@crotwell
Copy link
Owner

I feel your pain...
:(

@pskowronek
Copy link
Contributor Author

pskowronek commented Feb 27, 2024

Don't ask me why or what it does (I guess I'm not alone, but this gave me that hint), add this to app/build.gradle (after plugins): configurations.default.canBeResolved=true

Then I added config for macAppBundle:

macAppBundle {                                                                                                                                                               
    appName = 'Test'                                                                                                                                                         
    mainClassName = 'org.example.App'                                                                                                                                        
    appStyle = 'universalJavaApplicationStub'                                                                                                                                
                                                                                                                                                                             
    bundleJRE = false                                                                                                                                                        
    javaProperties.put('apple.laf.useScreenMenuBar', 'true')                                                                                                                 
    appIconX = 50                                                                                                                                                            
    appIconY = 120                                                                                                                                                           
    appFolderX = 330                                                                                                                                                         
    appFolderY = 120                                                                                                                                                         
}

./gradlew clean createApp succeeded and app was built.

@crotwell crotwell merged commit adc8411 into crotwell:master Feb 27, 2024
@crotwell
Copy link
Owner

Published...thanks for doing this.
https://plugins.gradle.org/plugin/edu.sc.seis.macAppBundle

@pskowronek
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants