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

Use the springBoot option when it is not null #213

Merged
merged 3 commits into from
Mar 31, 2021

Conversation

yuezk
Copy link

@yuezk yuezk commented Mar 30, 2021

I'm using the gretty plugin in a complex project, which has the org.springframework.boot group id in its complieClasspath and that could make gretty treat the project as a spring boot project, but actually it's not a standard spring boot application. So I want to tell gretty that it's not a spring boot project explicity.

I noticed that gretty has an undocumented option named springBoot that indicates whether the current project is a spring boot project or not. But we couldn't set it to false explicitly to indicates that a project is not a spring boot project. Because inside gretty, it will try to resolve the spring boot dependency when the springBoot option is a falsy value. I personally think it doesn't make sense when we the user set it to false explicitly.

wconfig.springBoot || (wconfig.projectPath && isSpringBootApp(project.project(wconfig.projectPath)))

So this PR is to solve the problem above. It will use the springBoot option set by the user with higher priority. And fallback to the spring boot detection logic if not set.

@yuezk yuezk marked this pull request as draft March 30, 2021 15:07
@yuezk yuezk marked this pull request as ready for review March 30, 2021 15:22
@boris-petrov
Copy link
Member

boris-petrov commented Mar 30, 2021

Sounds legit to me. But in this case, this method is no longer used on its own so it can be inlined in the other one I guess?

@boris-petrov boris-petrov requested a review from f4lco March 30, 2021 16:05
@yuezk
Copy link
Author

yuezk commented Mar 30, 2021

Sounds legit to me. But in this case, this method is no longer used on its own so it can be inlined in the other one I guess?

Updated.

@boris-petrov
Copy link
Member

@yuezk - thank you! Perhaps just leave the comment as it is still valid?

@f4lco - any other comments?

Copy link
Collaborator

@f4lco f4lco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Thank you, @yuezk!

@yuezk
Copy link
Author

yuezk commented Mar 31, 2021

@yuezk - thank you! Perhaps just leave the comment as it is still valid?

@f4lco - any other comments?

Makes sense, added the comment back.

@boris-petrov
Copy link
Member

Thanks for the contribution!

@boris-petrov boris-petrov merged commit 1d6d4cf into gretty-gradle-plugin:master Mar 31, 2021
boris-petrov pushed a commit that referenced this pull request Mar 31, 2021
* Using the springBoot property

* Improve the code structure

* Keep the comment
@yuezk yuezk deleted the fix_springBoot_option branch March 31, 2021 07:49
@yuezk
Copy link
Author

yuezk commented Mar 31, 2021

Hi @boris-petrov, is there a SNAPSHOT version that I can use? Thanks.

@boris-petrov
Copy link
Member

@yuezk - unfortunately not. :( We had until a day or two ago but since Bintray went read-only, we had to disable them. We'll re-enable them once we begin publishing to Maven Central but I can't promise when that will happen, sorry.

@f4lco
Copy link
Collaborator

f4lco commented Mar 31, 2021

@yuezk maybe you can try https://jitpack.io/#gretty-gradle-plugin/gretty/gretty-3.x-SNAPSHOT? Please report back if you find it useful and fixed your immediate problem.

@yuezk
Copy link
Author

yuezk commented Apr 2, 2021

@f4lco It doesn't work.

Here is the configuration

buildscript {
    repositories {
        maven { url 'https://jitpack.io' }
    }

    dependencies {
        classpath 'com.github.gretty-gradle-plugin:gretty:gretty-3.x-SNAPSHOT'
    }
}

apply plugin: 'org.gretty'

And here is the error message

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':LibraryRest'.
> Could not resolve all artifacts for configuration ':LibraryRest:classpath'.
   > Could not find com.github.gretty-gradle-plugin:gretty:gretty-3.x-SNAPSHOT.
     Searched in the following locations:
       - https://jitpack.io/com/github/gretty-gradle-plugin/gretty/gretty-3.x-SNAPSHOT/maven-metadata.xml
       - https://jitpack.io/com/github/gretty-gradle-plugin/gretty/gretty-3.x-SNAPSHOT/gretty-gretty-3.x-SNAPSHOT.pom
       - https://plugins.gradle.org/m2/com/github/gretty-gradle-plugin/gretty/gretty-3.x-SNAPSHOT/maven-metadata.xml
       - https://plugins.gradle.org/m2/com/github/gretty-gradle-plugin/gretty/gretty-3.x-SNAPSHOT/gretty-gretty-3.x-SNAPSHOT.pom
     Required by:
         project :LibraryRest

@f4lco
Copy link
Collaborator

f4lco commented Apr 6, 2021

@yuezk I don't know (and cannot reproduce) why some of the JitPack builds are failing. The branch build seems to be stuck, and I don't know if it is possible to restart JitPack builds. However, I had some luck referencing the commit ID:

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }

    dependencies {
        // classpath 'com.github.gretty-gradle-plugin:gretty:v3.0.4'
        classpath 'com.github.gretty-gradle-plugin:gretty:ff18c0057aeadd4574c32075c95905d2c8ef9ce4'
    }
}

apply plugin: 'org.gretty'
apply plugin: 'war'

repositories {
  mavenCentral()
  maven { url 'https://jitpack.io' }
}

configurations.all {
  resolutionStrategy {
    dependencySubstitution.all { dependency ->
      if (dependency.requested instanceof ModuleComponentSelector && dependency.requested.group == "org.gretty") {
        dependency.useTarget "com.github.gretty-gradle-plugin.gretty:${dependency.requested.module}:ff18c0057aeadd4574c32075c95905d2c8ef9ce4'"
      }
    }
  }
 }

My definition of "works" is equal to "can execute task showClasspath of the Gretty plugin" (it shows all dependencies of the runner and the webapp; if dependency resolution is broken, the task would likely detect that). Does that help you?

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.

3 participants