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

Source with gradle and maven build systems fails #423

Open
3 tasks done
scothis opened this issue Dec 21, 2021 · 12 comments
Open
3 tasks done

Source with gradle and maven build systems fails #423

scothis opened this issue Dec 21, 2021 · 12 comments
Labels
type:enhancement A general enhancement

Comments

@scothis
Copy link

scothis commented Dec 21, 2021

What happened?

  • Spring PetClinic has long had a maven build, recently a gradle build was added.

  • Using the latest tiny paketo builder, both the gradle and maven buildpacks detect. The gradle buildpacks runs, removes the source code, then the maven buildpacks fails running because it's unable to find a pom.xml

pack build scothis/petclinic
tiny: Pulling from paketobuildpacks/builder
Digest: sha256:9e6c4115045415035bb4eb356cb92b2f204bb2c6313e57d829907d30f0e1d390
Status: Image is up to date for paketobuildpacks/builder:tiny
tiny-cnb: Pulling from paketobuildpacks/run
Digest: sha256:1437105c9653b935ffba12ef35400ce7868e80465778759255a0da268fd7f1f2
Status: Image is up to date for paketobuildpacks/run:tiny-cnb
===> ANALYZING
Previous image with name "scothis/petclinic" not found
===> DETECTING
9 of 19 buildpacks participating
paketo-buildpacks/ca-certificates   3.0.1
paketo-buildpacks/bellsoft-liberica 9.0.1
paketo-buildpacks/syft              1.3.0
paketo-buildpacks/gradle            6.0.1
paketo-buildpacks/maven             6.0.1
paketo-buildpacks/executable-jar    6.0.1
paketo-buildpacks/apache-tomcat     7.0.2
paketo-buildpacks/dist-zip          5.0.1
paketo-buildpacks/spring-boot       5.2.0
===> RESTORING
===> BUILDING

Paketo CA Certificates Buildpack 3.0.1
  https://github.com/paketo-buildpacks/ca-certificates
  Launch Helper: Contributing to layer
    Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper

Paketo BellSoft Liberica Buildpack 9.0.1
  https://github.com/paketo-buildpacks/bellsoft-liberica
  Build Configuration:
    $BP_JVM_TYPE                 JRE             the JVM type - JDK or JRE
    $BP_JVM_VERSION              11              the Java version
  Launch Configuration:
    $BPL_DEBUG_ENABLED           false           enables Java remote debugging support
    $BPL_DEBUG_PORT              8000            configure the remote debugging port
    $BPL_DEBUG_SUSPEND           false           configure whether to suspend execution until a debugger has attached
    $BPL_HEAP_DUMP_PATH                          write heap dumps on error to this path
    $BPL_JAVA_NMT_ENABLED        true            enables Java Native Memory Tracking (NMT)
    $BPL_JAVA_NMT_LEVEL          summary         configure level of NMT, summary or detail
    $BPL_JFR_ARGS                                configure custom Java Flight Recording (JFR) arguments
    $BPL_JFR_ENABLED             false           enables Java Flight Recording (JFR)
    $BPL_JMX_ENABLED             false           enables Java Management Extensions (JMX)
    $BPL_JMX_PORT                5000            configure the JMX port
    $BPL_JVM_HEAD_ROOM           0               the headroom in memory calculation
    $BPL_JVM_LOADED_CLASS_COUNT  35% of classes  the number of loaded classes in memory calculation
    $BPL_JVM_THREAD_COUNT        250             the number of threads in memory calculation
    $JAVA_TOOL_OPTIONS                           the JVM launch flags
  BellSoft Liberica JDK 11.0.13: Contributing to layer
    Downloading from https://github.com/bell-sw/Liberica/releases/download/11.0.13+8/bellsoft-jdk11.0.13+8-linux-amd64.tar.gz
    Verifying checksum
    Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jdk
    Adding 128 container CA certificates to JVM truststore
    Writing env.build/JAVA_HOME.override
    Writing env.build/JDK_HOME.override
  BellSoft Liberica JRE 11.0.13: Contributing to layer
    Downloading from https://github.com/bell-sw/Liberica/releases/download/11.0.13+8/bellsoft-jre11.0.13+8-linux-amd64.tar.gz
    Verifying checksum
    Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jre
    Adding 128 container CA certificates to JVM truststore
    Writing env.launch/BPI_APPLICATION_PATH.default
    Writing env.launch/BPI_JVM_CACERTS.default
    Writing env.launch/BPI_JVM_CLASS_COUNT.default
    Writing env.launch/BPI_JVM_SECURITY_PROVIDERS.default
    Writing env.launch/JAVA_HOME.default
    Writing env.launch/JAVA_TOOL_OPTIONS.append
    Writing env.launch/JAVA_TOOL_OPTIONS.delim
    Writing env.launch/MALLOC_ARENA_MAX.default
  Launch Helper: Contributing to layer
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/active-processor-count
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/java-opts
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jvm-heap
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/link-local-dns
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/openssl-certificate-loader
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-configurer
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jmx
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jfr
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/nmt
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-classpath-9
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/debug-9
  Java Security Properties: Contributing to layer
    Writing env.launch/JAVA_SECURITY_PROPERTIES.default
    Writing env.launch/JAVA_TOOL_OPTIONS.append
    Writing env.launch/JAVA_TOOL_OPTIONS.delim

Paketo Syft Buildpack 1.3.0
  https://github.com/paketo-buildpacks/syft
    Downloading from https://github.com/anchore/syft/releases/download/v0.33.0/syft_0.33.0_linux_amd64.tar.gz
    Verifying checksum
    Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default

Paketo Gradle Buildpack 6.0.1
  https://github.com/paketo-buildpacks/gradle
  Build Configuration:
    $BP_GRADLE_BUILD_ARGUMENTS  --no-daemon assemble  the arguments to pass to Gradle
    $BP_GRADLE_BUILT_ARTIFACT   build/libs/*.[jw]ar   the built application artifact explicitly.  Supersedes $BP_GRADLE_BUILT_MODULE
    $BP_GRADLE_BUILT_MODULE                           the module to find application artifact in
    Creating cache directory /home/cnb/.gradle
  Compiled Application: Contributing to layer
    Executing gradlew --no-daemon assemble
      Downloading https://services.gradle.org/distributions/gradle-7.3.1-bin.zip
      ...........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%
      
      Welcome to Gradle 7.3.1!
      
      Here are the highlights of this release:
       - Easily declare new test suites in Java projects
       - Support for Java 17
       - Support for Scala 3
      
      For more details see https://docs.gradle.org/7.3.1/release-notes.html
      
      To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.3.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
      Daemon will be stopped at the end of the build 
      > Task :compileJava
      > Task :processResources
      > Task :classes
      > Task :bootJarMainClassName
      > Task :bootJar
      > Task :jar
      > Task :assemble
      
      BUILD SUCCESSFUL in 2m 1s
      5 actionable tasks: 5 executed
  Removing source code

Paketo Maven Buildpack 6.0.1
  https://github.com/paketo-buildpacks/maven
  Build Configuration:
    $BP_MAVEN_BUILD_ARGUMENTS  -Dmaven.test.skip=true package  the arguments to pass to Maven
    $BP_MAVEN_BUILT_ARTIFACT   target/*.[ejw]ar                the built application artifact explicitly.  Supersedes $BP_MAVEN_BUILT_MODULE
    $BP_MAVEN_BUILT_MODULE                                     the module to find application artifact in
    $BP_MAVEN_POM_FILE         pom.xml                         the location of the main pom.xml file, relative to the application root
  Apache Maven 3.8.4: Contributing to layer
    Downloading from https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.tar.gz
    Verifying checksum
    Expanding to /layers/paketo-buildpacks_maven/maven
    Creating cache directory /home/cnb/.m2
  Compiled Application: Contributing to layer
    Executing mvn --batch-mode -Dmaven.test.skip=true package
      [INFO] Scanning for projects...
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time:  0.320 s
      [INFO] Finished at: 2021-12-21T17:18:20Z
      [INFO] ------------------------------------------------------------------------
      [ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/workspace). Please verify you invoked Maven from the correct directory. -> [Help 1]
      [ERROR] 
      [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
      [ERROR] Re-run Maven using the -X switch to enable full debug logging.
      [ERROR] 
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
      unable to invoke layer creator
unable to contribute application layer
error running build
exit status 1
ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51

Build Configuration

Inspecting default builder: 'paketobuildpacks/builder:tiny'

Description: Tiny base image (bionic build image, distroless-like run image) with buildpacks for Java, Java Native Image and Go

Created By:
  Name: Pack CLI
  Version: 0.23.0+git-0db2c77.build-3056

Trusted: Yes

Stack:
  ID: io.paketo.stacks.tiny

Lifecycle:
  Version: 0.13.2
  Buildpack APIs:
    Deprecated: (none)
    Supported: 0.2, 0.3, 0.4, 0.5, 0.6, 0.7
  Platform APIs:
    Deprecated: (none)
    Supported: 0.3, 0.4, 0.5, 0.6, 0.7, 0.8

Run Images:
  index.docker.io/paketobuildpacks/run:tiny-cnb
  gcr.io/paketo-buildpacks/run:tiny-cnb

Buildpacks:
  ID                                                  NAME                                               VERSION        HOMEPAGE
  paketo-buildpacks/apache-tomcat                     Paketo Apache Tomcat Buildpack                     7.0.2          https://github.com/paketo-buildpacks/apache-tomcat
  paketo-buildpacks/azure-application-insights        Paketo Azure Application Insights Buildpack        5.1.1          https://github.com/paketo-buildpacks/azure-application-insights
  paketo-buildpacks/bellsoft-liberica                 Paketo BellSoft Liberica Buildpack                 9.0.1          https://github.com/paketo-buildpacks/bellsoft-liberica
  paketo-buildpacks/ca-certificates                   Paketo CA Certificates Buildpack                   3.0.1          https://github.com/paketo-buildpacks/ca-certificates
  paketo-buildpacks/clojure-tools                     Paketo Clojure Tools Buildpack                     2.0.1          https://github.com/paketo-buildpacks/clojure-tools
  paketo-buildpacks/dep                               Paketo Dep Buildpack                               0.2.0          https://github.com/paketo-buildpacks/dep
  paketo-buildpacks/dep-ensure                        Paketo Dep Ensure Buildpack                        0.2.0          https://github.com/paketo-buildpacks/dep-ensure
  paketo-buildpacks/dist-zip                          Paketo DistZip Buildpack                           5.0.1          https://github.com/paketo-buildpacks/dist-zip
  paketo-buildpacks/encrypt-at-rest                   Paketo Encrypt-at-Rest Buildpack                   4.0.1          https://github.com/paketo-buildpacks/encrypt-at-rest
  paketo-buildpacks/environment-variables             Paketo Environment Variables Buildpack             4.0.1          https://github.com/paketo-buildpacks/environment-variables
  paketo-buildpacks/executable-jar                    Paketo Executable JAR Buildpack                    6.0.1          https://github.com/paketo-buildpacks/executable-jar
  paketo-buildpacks/go                                Paketo Go Buildpack                                0.13.1         https://github.com/paketo-buildpacks/go
  paketo-buildpacks/go-build                          Paketo Go Build Buildpack                          0.6.0          https://github.com/paketo-buildpacks/go-build
  paketo-buildpacks/go-dist                           Paketo Go Distribution Buildpack                   0.8.2          https://github.com/paketo-buildpacks/go-dist
  paketo-buildpacks/go-mod-vendor                     Paketo Go Mod Vendor Buildpack                     0.4.0          https://github.com/paketo-buildpacks/go-mod-vendor
  paketo-buildpacks/google-stackdriver                Paketo Google Stackdriver Buildpack                5.1.1          https://github.com/paketo-buildpacks/google-stackdriver
  paketo-buildpacks/gradle                            Paketo Gradle Buildpack                            6.0.1          https://github.com/paketo-buildpacks/gradle
  paketo-buildpacks/image-labels                      Paketo Image Labels Buildpack                      4.0.1          https://github.com/paketo-buildpacks/image-labels
  paketo-buildpacks/java                              Paketo Java Buildpack                              6.3.0          https://github.com/paketo-buildpacks/java
  paketo-buildpacks/java-native-image                 Paketo Java Native Image Buildpack                 7.3.0          https://github.com/paketo-buildpacks/java-native-image
  paketo-buildpacks/leiningen                         Paketo Leiningen Buildpack                         4.0.1          https://github.com/paketo-buildpacks/leiningen
  paketo-buildpacks/maven                             Paketo Maven Buildpack                             6.0.1          https://github.com/paketo-buildpacks/maven
  paketo-buildpacks/native-image                      Paketo Native Image Buildpack                      5.0.1          https://github.com/paketo-buildpacks/native-image
  paketo-buildpacks/procfile                          Paketo Procfile Buildpack                          5.0.1          https://github.com/paketo-buildpacks/procfile
  paketo-buildpacks/sbt                               Paketo SBT Buildpack                               6.0.3          https://github.com/paketo-buildpacks/sbt
  paketo-buildpacks/spring-boot                       Paketo Spring Boot Buildpack                       5.2.0          https://github.com/paketo-buildpacks/spring-boot
  paketo-buildpacks/syft                              Paketo Syft Buildpack                              1.3.0          https://github.com/paketo-buildpacks/syft
  paketo-buildpacks/upx                               Paketo UPX Buildpack                               3.0.0          https://github.com/paketo-buildpacks/upx
  paketo-buildpacks/watchexec                         Paketo Watchexec Buildpack                         2.0.1          https://github.com/paketo-buildpacks/watchexec

Detection Order:
 ├ Group #1:
 │  └ paketo-buildpacks/java-native-image@7.3.0
 │     └ Group #1:
 │        ├ paketo-buildpacks/ca-certificates@3.0.1          (optional)
 │        ├ paketo-buildpacks/upx@3.0.0                      (optional)
 │        ├ paketo-buildpacks/bellsoft-liberica@9.0.1
 │        ├ paketo-buildpacks/syft@1.3.0                     (optional)
 │        ├ paketo-buildpacks/leiningen@4.0.1                (optional)
 │        ├ paketo-buildpacks/gradle@6.0.1                   (optional)
 │        ├ paketo-buildpacks/maven@6.0.1                    (optional)
 │        ├ paketo-buildpacks/sbt@6.0.3                      (optional)
 │        ├ paketo-buildpacks/executable-jar@6.0.1           (optional)
 │        ├ paketo-buildpacks/spring-boot@5.2.0              (optional)
 │        ├ paketo-buildpacks/native-image@5.0.1
 │        ├ paketo-buildpacks/procfile@5.0.1                 (optional)
 │        ├ paketo-buildpacks/environment-variables@4.0.1    (optional)
 │        └ paketo-buildpacks/image-labels@4.0.1             (optional)
 ├ Group #2:
 │  └ paketo-buildpacks/java@6.3.0
 │     └ Group #1:
 │        ├ paketo-buildpacks/ca-certificates@3.0.1               (optional)
 │        ├ paketo-buildpacks/bellsoft-liberica@9.0.1
 │        ├ paketo-buildpacks/syft@1.3.0                          (optional)
 │        ├ paketo-buildpacks/leiningen@4.0.1                     (optional)
 │        ├ paketo-buildpacks/clojure-tools@2.0.1                 (optional)
 │        ├ paketo-buildpacks/gradle@6.0.1                        (optional)
 │        ├ paketo-buildpacks/maven@6.0.1                         (optional)
 │        ├ paketo-buildpacks/sbt@6.0.3                           (optional)
 │        ├ paketo-buildpacks/watchexec@2.0.1                     (optional)
 │        ├ paketo-buildpacks/executable-jar@6.0.1                (optional)
 │        ├ paketo-buildpacks/apache-tomcat@7.0.2                 (optional)
 │        ├ paketo-buildpacks/dist-zip@5.0.1                      (optional)
 │        ├ paketo-buildpacks/spring-boot@5.2.0                   (optional)
 │        ├ paketo-buildpacks/procfile@5.0.1                      (optional)
 │        ├ paketo-buildpacks/azure-application-insights@5.1.1    (optional)
 │        ├ paketo-buildpacks/google-stackdriver@5.1.1            (optional)
 │        ├ paketo-buildpacks/encrypt-at-rest@4.0.1               (optional)
 │        ├ paketo-buildpacks/environment-variables@4.0.1         (optional)
 │        └ paketo-buildpacks/image-labels@4.0.1                  (optional)
 ├ Group #3:
 │  ├ paketo-buildpacks/go@0.13.1
 │  │  └ Group #1:
 │  │     ├ paketo-buildpacks/ca-certificates@3.0.1          (optional)
 │  │     ├ paketo-buildpacks/watchexec@2.0.1                (optional)
 │  │     ├ paketo-buildpacks/go-dist@0.8.2
 │  │     ├ paketo-buildpacks/go-mod-vendor@0.4.0
 │  │     ├ paketo-buildpacks/go-build@0.6.0
 │  │     ├ paketo-buildpacks/procfile@5.0.1                 (optional)
 │  │     ├ paketo-buildpacks/environment-variables@4.0.1    (optional)
 │  │     └ paketo-buildpacks/image-labels@4.0.1             (optional)
 │  ├ paketo-buildpacks/go@0.13.1
 │  │  └ Group #2:
 │  │     ├ paketo-buildpacks/ca-certificates@3.0.1          (optional)
 │  │     ├ paketo-buildpacks/watchexec@2.0.1                (optional)
 │  │     ├ paketo-buildpacks/go-dist@0.8.2
 │  │     ├ paketo-buildpacks/dep@0.2.0
 │  │     ├ paketo-buildpacks/dep-ensure@0.2.0
 │  │     ├ paketo-buildpacks/go-build@0.6.0
 │  │     ├ paketo-buildpacks/procfile@5.0.1                 (optional)
 │  │     ├ paketo-buildpacks/environment-variables@4.0.1    (optional)
 │  │     └ paketo-buildpacks/image-labels@4.0.1             (optional)
 │  └ paketo-buildpacks/go@0.13.1
 │     └ Group #3:
 │        ├ paketo-buildpacks/ca-certificates@3.0.1          (optional)
 │        ├ paketo-buildpacks/watchexec@2.0.1                (optional)
 │        ├ paketo-buildpacks/go-dist@0.8.2
 │        ├ paketo-buildpacks/go-build@0.6.0
 │        ├ paketo-buildpacks/procfile@5.0.1                 (optional)
 │        ├ paketo-buildpacks/environment-variables@4.0.1    (optional)
 │        └ paketo-buildpacks/image-labels@4.0.1             (optional)
 └ Group #4:
    └ paketo-buildpacks/procfile@5.0.1

Checklist

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.
@dsyer
Copy link

dsyer commented Dec 22, 2021

There's a workaround for the Petclinic which is to set BP_MAVEN_POM_FILE to a non-existent file. E.g.

$ pack --env BP_MAVEN_POM_FILE=no-such-file.xml build dsyer/petclinic
...
aving dsyer/petclinic...
*** Images (9738aa16341a):
      dsyer/petclinic
Adding cache layer 'paketo-buildpacks/bellsoft-liberica:jdk'
Adding cache layer 'paketo-buildpacks/syft:syft'
Adding cache layer 'paketo-buildpacks/gradle:application'
Adding cache layer 'paketo-buildpacks/gradle:cache'
Adding cache layer 'cache.sbom'
Successfully built image dsyer/petclinic

Unfortunately that doesn't work for all projects because there is no corresponding env entry for the Gradle buildpack (you can't switch it off).

@dmikusa
Copy link
Contributor

dmikusa commented Dec 22, 2021

I can remember this coming up once before. Someone accidentally had their project set up such that it triggered both Maven and Gradle. At the time, we didn't make any changes because it was essentially a user error and we couldn't think of a case where you'd want both.

Can someone elaborate on why there are two build systems? And what is the desired outcome here? Should it be running both? Should it only run one? If so, which one should it pick?

Thanks

@dsyer
Copy link

dsyer commented Dec 22, 2021

It's quite common with demos and guides (all of the guides on spring.io for instance). I would expect the user to be able to choose at least, if we can't come up with a sensible default. In the case of the Petclinic I would want the Maven build to be the "source of truth".

@scothis
Copy link
Author

scothis commented Dec 22, 2021

Based on the current behavior, it seems that the gradle and maven buildpacks are mutually exclusive. Should they be moved into independent groups and made non-optional within the respective group? Then whichever build system is listed first would "win". If the order picks wrong for the project, then you can use something like the work around Dave mentioned (hopefully that's rare).

@dmikusa dmikusa added the type:enhancement A general enhancement label Dec 23, 2021
@dmikusa
Copy link
Contributor

dmikusa commented Dec 23, 2021

Ok, that makes sense for demos and guides. You don't know which tool the user would be using so you support both.

The trouble from the buildpack perspective is that you don't know what the user would prefer. The typical signal for what the user prefers is what build files they have included. Since there are both, we don't really know which one to use. We could pick one, but then we end up making the decision for the user and that'll never be right 100% of the time.

We can definitely do better.

A few thoughts:

  1. It would be a little awkward, but we could more strongly enforce the buildpacks' assumption that there is a mutually exclusive relationship with the build tools & if multiple are detected then we have a more friendly error message. Possibly instructing the user how to proceed. I think this would be the most correct option, we'd never make the wrong choice, but also the least user-friendly as we'd require the user to resolve the conflict which is more work.

  2. I think we could do something similar and provide a guard in the build tools buildpacks such that if multiple pass detection at the same time, only one would run at build time (the others would no-op). Basically, they would perform a similar check to detection prior to building. If that passed at detect, but failed at build then we could assume that another build tools buildpack ran and processed the application since the last thing a build tools buildpack does is delete the application files. This would result in whatever is first in the order group winning. That may or may not be what the user wants, but with demo apps it is probably the friendliest approach. They would at least build out-of-the-box. We'd then have to have some way of overriding the default behavior, so a user could force a particular build tool to be used.

  3. A third possibility would be to make an indicator, possibly a hidden file, that you could embed in the project to indicate which you as the demo project author thing should be the default (unless I'm overlooking something that would naturally exist to differentiate). @dsyer mentioned that for PetClinic Maven should be the default, but I suspect for other demo authors Gradle might be the preferred default. Neither of the above two options would accommodate this author preferred default scenario. This is slightly different from an environment variable as well in that the demo author could pick this default and it's applied automatically, whereas with env variables the user would have to set something, possibly copied out of the README for the demo. That puts a little more work on the user of the demo.

Thoughts or preferences on the options above? I'm open to options I may have missed as well.

@kiwi-bui
Copy link

Has there been any development on an ability to specify what build pack to use by any chance?

@dmikusa
Copy link
Contributor

dmikusa commented Mar 10, 2023

@kiwi-bui Not in terms of automating this. The trouble is that when you have both, the buildpack can't know which one to pick. It requires user intervention.

You can force one or the other. See #423 (comment) which shows the workaround. The same config setting exists for Gradle, so you can do the same workaround with it as well.

@c0d1ngm0nk3y
Copy link
Contributor

Thoughts or preferences on the options above? I'm open to options I may have missed as well.

How about adding the user the possibility to fix this at least?

Sure, it works by setting BP_MAVEN_POM_FILE, but it is not that intuitive and sounds a bit hacky, doesn't it? How about BP_MAVEN_ENABLED and BP_GRADLE_ENABLED?

@dsyer
Copy link

dsyer commented May 26, 2023

The Gradle build pack now has the corresponding build file env var. You can set it to a non-existent file and the buildpack will pick Maven.

@dmikusa
Copy link
Contributor

dmikusa commented May 30, 2023

Sure, it works by setting BP_MAVEN_POM_FILE, but it is not that intuitive and sounds a bit hacky, doesn't it? How about BP_MAVEN_ENABLED and BP_GRADLE_ENABLED?

This is an option that I was specifically trying to not do. I would rather fix this problem in a way that the user doesn't have to intervene. I think having these _ENABLED flags could also potentially be confusing as it could be unclear if users need to always set these (i.e. even if there is just a pom.xml or build.gradle file, not both) to perform a build, so I worry it could impact new user experience in general, not just this specific use case.

Anyway, we haven't actually looked at fixing this in a more permanent way because the main places where this has been reported are demo apps, because fixing this would be a high level of effort, and because there is a fairly simple workaround (also not new-user friendly, but it does work).

@c0d1ngm0nk3y
Copy link
Contributor

This is an option that I was specifically trying to not do. I would rather fix this problem in a way that the user doesn't have to intervene.

But in any case, the user needs a way to intervene. The question is always or "just" is the buildpacks took the "wrong" decision.

I think having these _ENABLED flags could also potentially be confusing as it could be unclear if users need to always set these (i.e. even if there is just a pom.xml or build.gradle file, not both) to perform a build, so I worry it could impact new user experience in general, not just this specific use case.

Would it though? The user only knows about these from the documentation and the default is then documented as true. And it would be very clear what they are doing. So I don't see any room for confusion what so ever.

Anyway, we haven't actually looked at fixing this in a more permanent way because the main places where this has been reported are demo apps, because fixing this would be a high level of effort

Yes, I doubt that it is worth it for this quite specific case.

and because there is a fairly simple workaround (also not new-user friendly, but it does work).

When when talking about user experience, this "workaround" is far from ideal. TBH, I don't see any difference to _ENABLED other than it is harder to discover and understand. You could even argue that your point with the user confusion could be made here as well - do the user always have to set this?

@anthonydahanne
Copy link
Member

For people returning to this issue in 2024; here's the current status:

Provided you have source code that includes both build.gradle(.kts) and pom.xml :

  • The Java buildpack default order is to pick Gradle first, and then Maven; Maven won't do anything though
  • If you only want Maven to be part of the build, then set: BP_GRADLE_BUILD_FILE=nope.gradle - gradle won't participate AT ALL
  • If you only want Gradle to be part of the build, then set: BP_MAVEN_POM_FILE=nope.xml - maven won't participate AT ALL

If you believe there should be _ENABLED options, because those workarounds are not good enough, IMO you should probably first re consider having both build.gradle andpom.xml in your source.

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

No branches or pull requests

6 participants