can anyone recommend ways to package a java pulumi...
# general
f
can anyone recommend ways to package a java pulumi app with the azure provider? I have considered GraalVM but is another layer. I saw options of doing it natively even though it might be a bit heavy. I have tested with the FatJar choice using a gradle plugin called Shadow but it failed. any suggestions are welcome.
a
I use this to build a fat jar
Copy code
<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.4.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>${mainClass}</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.7.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>${mainClass}</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-my-jar-with-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.5.0</version>
                <configuration>
                    <mainClass>${mainClass}</mainClass>
                    <commandlineArgs>${mainArgs}</commandlineArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-wrapper-plugin</artifactId>
                <version>3.3.2</version>
                <configuration>
                    <mavenVersion>3.9.9</mavenVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
                <configuration>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
        </plugins>
    </build>
Copy code
-rw-r--r--  1 user  staff   148M May 26 22:08 deploy-infra-1.1-SNAPSHOT-jar-with-dependencies.jar
1
f
i've seen
maven-shade-plugin
used as well. With Gradle Shadow you may have had duplicate META-INF/services? i.e. use
mergeServiceFiles()
per this I don't want to make assumptions, check out runtime.options.binary if you haven't; it may be helpful
👀 1
f
thanks. The Fatjar option with Shadow is rather hacky. I tried building the fulll java distribution but pulumi dislikes it
Copy code
error: failed to discover package requirements: language host could not determine Pulumi packages: could not find ./sbt, sbt on the $PATH: exec: "sbt": executable file not found in $PATH
f
do you have a
build.sbt
in your pulumi project directory? seems odd for it to be asking for
sbt
if you aren't using it and don't have it installed though
👀 1
f
@future-hairdresser-70637 it is very odd. I had more success with the gradle Kotlin Fat Jar approach.
No i dont have a
.sbt
@adamant-lawyer-19698 and then you just do
pulumi up
???
there must be some settings in the Pulumi.yaml pointing to a binary
f
if you are specifying
binary
that would be one reason; feel free to paste your Pulumi.yaml and we can look
f
Copy code
name: kubernetes-azure-spinnaker # Project name
description: Spinnaker Stack on Azure Kubernetes
runtime:
  name: java
  options:
    binary: gradle run --console=plain
    # Point directly to the generated Bash script, NOT a .jar file
    # binary: kubernetes-azure-spinnaker/bin/kubernetes-azure-spinnaker
packages:
  azure-native:
    version: 3.18.0

config:
  pulumi:tags:
    value:
      pulumi:template: azure-java
  azure-native:location:
    description: The Azure location to deploy resources to
    value: eastus
  resourceGroupName:
    description: The name of the resource group
    value: anz-devops-sre-platform-engineering-research-dev
# plugins:
#   providers:
#     - name: azure-native
#       version: 3.18.0
f
Huh. I'm a bit surprised that even sort of works 😅 the dev docs say
binary
should be "A string that specifies the path of a pre-build Java JAR file or a JBang entry-point file to execute"
f
my friend Gemini recommended that option. from what @adamant-lawyer-19698 has commented the way to go would be to use a very big Fat Jar 🙂 thanks everyone.
👍 2