fnproject/cli

fn build doesn't honor settings.xml

dashorst opened this issue · 6 comments

For wider adoption of the FN project the Java artifacts should not only work using artifacts from bintray, but also through company required Maven repositories that restrict incoming artifacts to company approved artifacts (which is why it is adamant that fn project Java dependencies be available from Maven Central). This is typically done by setting a mirror in the user's settings.xml, which is honored by the Maven commandline and other tooling. However the fn build command invokes a docker based Maven that ignores the user settings and hence the companies' policies.

Also, the build is currently duplicating download efforts because the build doesn't utilize the local m2 repository, but insists on creating a separate structure inside the docker image.

Steps to reproduce the issue:
0. use a <mirror> in your settings.xml to point to a (local) artifactory that mirrors Maven Central (and possibly the fn project bintray repository)

  1. start a new fn project
  2. remove the <repositories> section from the pom.xml file
  3. mvn package (this should not fail)
  4. fn build

Describe the results you received:

[ERROR] Failed to execute goal on project banana-status: Could not resolve dependencies for project education.topicus.banana:banana-status:jar:1.0.0: The following artifacts could not be resolved: com.fnproject.fn:api:jar:1.0.85, com.fnproject.fn:testing-core:jar:1.0.85, com.fnproject.fn:testing-junit4:jar:1.0.85: Failure to find com.fnproject.fn:api:jar:1.0.85 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR] 

This error explicitly mentions https://repo.maven.apache.org/maven2 as the repository, but that is not what is specified in settings.xml

Describe the results you expected:

A build that works like mvn package (as that is run through the Docker build), and not one that fails because artifacts could not be found.

This issue can be partially solved by deploying the released Java artifacts to Maven Central, but only because the Docker build then only connects to Maven Central, while still circumventing the company provided repository.

Possible solution

If present, mount the ~/.m2 folder in the Docker build image under the appropriate folder for Maven. This allows the fn build to also use the cached artifacts stored there, thus improving build times considerably by not downloading all artifacts twice.

Hi! Again, Fn is not implemented with Java. The only project that uses Java is FDK-Java, so, there’s only one artifact that is in bintray.

So, fn build doesn’t work with maven and it’s things.

If you’d like to have FDK-Java published in maven central - please open corresponding issue at fdk-java repo.

If you’d like to build an image with whatever you have in .m2 - write your own dockerfile, that’s the way to build functions that need 3rd-party deps.

This type of problem is not unique to Java, if something doesn’t fit into Fn in terms of building functions - please write your own dockerfile.

@dashorst hi, were you able to solve the problem with my recommendations?

Nope. I gave up.

If you need any help please post your question. If you need to install some dependencies you’d need to write your own dockerfile (which is easy enough as long as you know how to pack your code into docker container).

I’m going to close this issue. But will open another one to add support for Java builds from local maven cache.