Search code examples
gitmavenapigee

Bizarre missing resource for Apigee deploy, possible Maven issue on Windows?


So I get this error:

[ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.0.1:deploy (default-cli) on project reporting: MojoExecutionException: com.google.api.client.http.HttpResponseException: 400 Bad Request
[ERROR] {
[ERROR] "code" : "messaging.config.beans.InvalidResourceURLRef",
[ERROR] "message" : "Invalid resource url ref jsc://js_validateReportingWriteScope3.js in policy js_validateReportingWriteScope3 in cambiahealth-nonprod",
[ERROR] "contexts" : [ ],
[ERROR] "cause" : {
[ERROR] "code" : "messaging.config.beans.ResourceDoesNotExist",
[ERROR] "message" : "Resource with name js_validateReportingWriteScope3.js and type jsc does not exist",

The file definitely exists. I've tried:

  1. mvn clean
  2. mvn dependency:purge-local-repository
  3. IntelliJ invalidate caches and restart
  4. Deleting all the local files and cloning from the remote repo
  5. I tried renaming the file to a new name, in hopes it would pick up the new filename (hence why you see "3" in the filenames)

My coworkers can do the deploy, but they are on Macs. I'm on Windows.

The command that fails is:

mvn apigee-enterprise:deploy -P$environment -Dusername=$username -Dpassword=$password

The command that works (but we don't want to use, because it wipes the current deploy and replaces it, losing historical info):

mvn apigee-enterprise:deploy -P$environment -Dapigee.options=clean -Dusername=$username -Dpassword=$password

What should I try? This error makes no sense to me. The .js file definitely exists.


Solution

  • Putting this XML block below in the parent POM solves the immediate issue; however, note that it has created a side effect for me: it is breaking our inclusion of additional Apigee policies that come from a parent POM and a "common" proxy that's outside the current one. As such, this is only a partial solution. My ultimate solution will be to convert over to a Mac, because this issue is only happening on Windows computers.

    <!-- copy the full apiproxy folder to target folder -->
    <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
            <execution>
                <id>copy-resources</id>
                <phase>package</phase>
                <goals>
                    <goal>copy-resources</goal>
                </goals>
                <configuration>
                     <!--this is important -->
                    <overwrite>true</overwrite>
                     <!--target -->
                    <outputDirectory>${target.root.dir}/apiproxy</outputDirectory>
                    <resources>
                        <resource>
                             <!--source -->
                            <directory>${project.root.dir}/apiproxy</directory>
                        </resource>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>