azure.yaml
schema change to support Java .jar packaging
#741
Replies: 1 comment
-
My thinking is that we should use Option A here and allow users who need to change this to just set
Here I also think the implicit strategy makes sense (including failing when multiple JAR files are detected in whatever folder FWIW - this feels somewhat similar to what we were discussing for project files for .NET based projects (where there could be multiple
but perhaps with the above design that should instead be something like:
I have a slight preference for just including the file name as part of the path component but would be open to something a little more verbose. This also makes me wonder if we would want to support something like:
For cases where there are multiple
It feels like the general pattern here is: "implicit based on conventions from the tool/ecosystem we are interacting with by default, with overrides in |
Beta Was this translation helpful? Give feedback.
-
Background
Java applications are most commonly packaged into a single .JAR / .EAR / .WAR archive file that is deployed.
When deployed as a docker container, this poses no issues as the user can explicitly define how packaging works in the Dockerfile.
azd
simply deploys the container produced.However, when it comes to ZIP deployments for App service / function apps,
azd
requires understanding of how the application is packaged which is configured by the user inazure.yaml
. Thus, additional configuration is required by the user to specify exactly how this is achieved.Background: how azd packaging works
Currently,
azd
allows specifyingdist
as a relative path directory to create a ZIP deployment folder. This is the current schema description:Background: how maven packaging works
Maven projects are encouraged to follow maven standard directory layout.
target
is the root directory of all build outputs and cannot be changed directly via a CLI parameter inmvn package
(unlikedotnet publish -o <OUTPUT_DIRECTORY>
). The build output directory can only be customized via changing the build configuration files itself.The
target
directory contains all build outputs, as well as the final runnable JAR file that serves the application's entrypoint. An example is shown below withsimple-todo-0.0.1-SNAPSHOT.jar
being the final produced output:Question: How should we treat
dist
for Java?Option A: Implicit
dist
is assumed to be<project>/target
for Maven since this is the standard convention.Option B: Explicit
dist
is a required field forJava
/maven
. The help examples would point at the likely value being./target
.Question: How should we package *.JAR files?
Option A: Implicit
By default, for
Java
projects, we will NOT include all files and directories underdist
, but rather to include JAR files underdist
.Example:
Will result in
azd
packaging the single JAR file found under<project>/target
. If multiple JAR files are found, a packaging error is encountered duringazd deploy
.Option B: Explicit via glob patterns
This introduces the notion of "globbing" patterns for
azd
. Without going into too much detail (like to just get agreement on this), we would introduce a globbing pattern mechanism similar how to most CI workflow tasks for packaging works. A set of glob patterns viadistGlobPatterns
can be defined that matches files relative todist
. When performing file copy, all files are copied to relative to thedist
directory specified.Example:
Will result in
azd
packaging the JAR files found under<project>/target
. If multiple JAR files are found, a packaging error is encountered duringazd deploy
. This allows multiple files other than JAR to be included in the final zip directory (not sure how useful this is). It can also allow potentially resolving a single JAR if multiple JARs were present.It is also an error if no JAR files were resolved. This would be enforced at packaging time. A potential compile-time schema validation could validate at least one expression has suffix
.jar
or*
(less restrictive than actual).For backcompat behavior, if no
distGlobPatterns
were specified, it is treated as ifdistGlobPatterns: **
was provided.Furthermore, this can allow us to extract out implicit logic we currently have for
python
,js
to excludenode_modules
,__pycache__
and allow user to specify it directly.We can also introduce a breaking change to simplify / refactor config if desirable:
Beta Was this translation helpful? Give feedback.
All reactions