crotwell / gradle-macappbundle

A Gradle Plugin to create a Mac OSX .app application and dmg based on the project.
Apache License 2.0
96 stars 33 forks source link

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

Closed pskowronek closed 7 months ago

pskowronek commented 8 months ago

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

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

I feel your pain... :(

pskowronek commented 7 months ago

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 commented 7 months ago

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

pskowronek commented 7 months ago

Thanks!