I’m having issues with loading Java resources in o...
# java
b
I’m having issues with loading Java resources in one of the dependency I use in my Pulumi stack code. I tried to fine tune the Maven exec plugin, but I’m not getting anywhere. What’s the best way to debug how the Pulumi CLI calls Maven? Can I pass some extra flags, like
-X
?
MAVEN_ARGS=-X
worked, but when I first tried
MAVEN_OPTS
with
pulumi up
it started deleting all resources 😄
a
good to know
b
I couldn’t figure that out. I don’t know Maven well enough
a
You may share pom.xml.
b
I’m not sure if I can, but I can describe it in more detail. I’ve got a class in module A that loads a property file from resources:
Copy code
URL resource = Resources.getResource("values.properties");
Then I reference this class in my Pulumi app (module B), pulling it as a regular dependency:
Copy code
<dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>moduleA</artifactId>
        </dependency>
and
pulumi up
throws this:
Copy code
Caused by: java.lang.IllegalArgumentException: resource values.properties not found.
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:218)
        at com.google.common.io.Resources.getResource(Resources.java:196)
        at packageA.ClassA.<clinit>(ClassA.java:39)
I tried a few things, like: • copying this property to moduleB, under the same path • enabling
<addResourcesToClasspath>
for the exec-maven-plugin • different values for
<classpathScope>
• adding it explicitly to the class path by adding it to
<additionalClasspathElements>
, confirmed with
mvn -X
that it’s set I don’t think it’s an issue with Pulumi itself, just exec-maven-plugin, but I wonder if Pulumi has to use it, or could it run the program from a jar
I remember having similar issues with loading resources in dependencies when executing tests, so it’s not uncommon. As a last resort, I can just copy this resource to moduleB, and load it there
hmm I can try the
binary
option in
Pulumi.yaml
I got it working with a shaded (fat?) jar, but it was not easy, and even the template created with
pulumi new java
doesn’t have the correct pom.xml for this