Deploying Cloud Function with private dependencies - java

this is my first question on SO I'll try my best to make it good.
My team deploys multiple Java Cloud Functions (GCP) using a few common classes (with maven to manage dependencies). Right now those classes are duplicated in each function and have to be updated everywhere at each code edit. Each Cloud Function is deployed from source.
To avoid duplicating those classes I packaged them in a jar, everything runs fine locally. I added this jar as a local dependency in each Cloud Function pom file and tried to deploy from jar by building a jar with all dependencies and providing it in the --source option of gcloud deploy. This causes a timeout error from what seems to be the jar uploading.
Error trace :
DEBUG: Starting new HTTPS connection (1): storage.googleapis.com:443
DEBUG: Caught socket error, retrying: ('Connection aborted.', timeout('The write operation timed out',))
What I tried so far :
Setting a higher deployment timeout with gcloud config set app/cloud_build_timeout 10000 but this doesn't seem to apply to the uploading step as it fails always after a few minutes.
Uploading my local dependency to a private nexus repository to deploy my functions from source as before, but the pull failed on a Wagon error when I run mvn package and I didn't find any solution either : WagonTransporterFactory: Unsupported transport protocol
Detailed error :
[ERROR] Failed to execute goal on project get-content: Could not resolve dependencies for project project:cf:jar:1.0: Failed to collect dependencies at project:pipeline:jar:0.0.1: Failed to read artifact descriptor for project:pipeline:jar:0.0.1: Could not transfer artifact project:pipeline:pom:0.0.1 from/to project-nexus (XXX): Cannot access XXX with type default using the available connector factories: BasicRepositoryConnectorFactory: Cannot access XXX using the registered transporter factories: WagonTransporterFactory: Unsupported transport protocol -> [Help 1]
I beleive this is only due to my jar with dependencies being to large for upload as I actually deployed the jar without dependency by mistake first (deploy succeded but class definition missing during execution). My question is how can I deploy my Cloud Function with one local/private dependency ?
Note :
I can't upload my dependency to a public maven repository
Each Cloud Function depends also on public maven dependencies which seems to be too large to package in a single jar for deployment

I solved this by switching from Maven to Gradle.
The problem was that Maven stores the repository authentification parameters in a local file ~/.m2/settings.xml that Google Build can't access when building my Cloud Function for deployment.
I switched to Gradle to provide the authenfication in the gradle.build file directly following this question.

Related

while adding poi -ooxml dependency in sts4 I am getting an error - cannot transfer

I am getting an error while adding poi - ooxlm dependency in my Rest assured project . I need to add Excel file interaction to handle data .
The error I am getting is "Could not transfer artifact org.apache.poi:poi-ooxml-lite:jar:5.2.2 from/to snapshots (https://artifacts.apple.com/libs-snapshot): artifacts.apple.com org.eclipse.aether.transfer.ArtifactTransferException: Could
not transfer artifact org.apache.poi:poi-ooxml-lite:jar:5.2.2 from/to snapshots (https://artifacts.apple.com/libs-snapshot): artifacts.apple.com at "
my pom.xml is
You don't show much of the relevant parts of your pom.xml; also including the relevant snippets as text is easier than a screenshot.
But org.apache.poi:poi-ooxml-lite is available on maven central, so that's where your project should look.
https://artifacts.apple.com/libs-snapshot does not resolve for me, this might be a company internal maven repository that you're using?
There are a few things you can check:
Open the file .m2\repository\org\apache\poi\poi-ooxml-lite\5.2.2\poi-ooxml-lite-5.2.2.jar.lastUpdated and check the error message for each repository. Check why it can't reach maven central; is it missing from the list or giving an error? This might be a company firewall/policy issue perhaps? Or is it giving an error on HTTPS/TLS protocol level?
Check with mvn help:effective-pom what your current listed (plugin) repositories are
Check if you can add maven central to your repositories list if it's missing somehow (should be included by default). Check if it's HTTP or HTTPS, only secure is supported now.
Check in your main maven repository which versions of this jar are available / mirrored, and depend on that version instead (if you can't get maven central to work).
Run your maven command with -X for debug mode to investigate further

Gradle Build Error: Failed to appy plugin[class 'org.gradle.api.plugins.JavaPlugin

Gradle Build fails with the above error. I am going thru firewall and proxy server settings. I do have local nexus repository hosted in the company network.
The module which is failing uses free marker templates and bundles them into a deployable jar. I suspect I am not including the java plugin in the repository.
Gradle plugin resolution uses a different configuration than dependency resolution.
You most likely need to customise it as well. The exact details will depend on your setup and constraints.
See the relevant documentation

How generate a Fat Maven Plugin with maven-plugin-plugin?

In our company, we've created a Maven plugin using maven-plugin-plugin v3.5, that normally contains 20kb.
The issue begun two days ago, because repo.jenkins-ci.org proxy is not working properly. So, our clients builds were affected because it wasn't possible to download the dependencies of our plugins, failing builds due:
Failed to collect dependencies at our-project:jar:1.6.2 -> our-project:jar:1.6.2 -> com.devfactory.utqg:utqg-github:jar:1.6.2 -> org.kohsuke:github-api:jar:1.77 -> com.infradna.tool:bridge-method-annotation:jar:1.14 -> org.jenkins-ci:annotation-indexer:jar:1.4: Failed to read artifact descriptor for org.jenkins-ci:annotation-indexer:jar:1.4: Could not transfer artifact org.jenkins-ci:jenkins:pom:1.26 from/to repo.jenkins-ci.org (http://repo.jenkins-ci.org/public/): Failed to transfer file: http://repo.jenkins-ci.org/public/org/jenkins-ci/jenkins/1.26/jenkins-1.26.pom. Return code is: 502 , ReasonPhrase:Bad Gateway. -> [Help 1]
So, our approach to that problem was focused in creating a Fat Maven Plugin (not a Fat Jar!). But, using Maven Shade plugin is not suitable for copying the artifacts, because plugin execution fails due the jar signature.
Does anybody have generated a fat Maven plugin? If yes, how?
The issue begun two days ago, because repo.jenkins-ci.org proxy is not
working properly. So, our clients builds were affected because it wasn't possible to download the dependencies of our plugins,
I recommend to run your own Maven Repository Manager to avoid these kind of issues: https://maven.apache.org/repository-management.html
Configure the single group in your settings.xml (mirror): http://books.sonatype.com/nexus-book/2.8/reference/maven-sect-single-group.html
Don't manage repositories in your POMs, but only as proxies in your Maven Repository Manager.

How to resolve dependencies in Bamboo build?

I have created bamdoo build wich checkouting git repository and started sbt build with tests. There are several sbt reposotories including one from local network. So bamboo build fails with strange message:
[0m ::::::::::::::::::::::::::::::::::::::::::::::[0m
[0m :: UNRESOLVED DEPENDENCIES ::[0m
[0m ::::::::::::::::::::::::::::::::::::::::::::::[0m
[0m :: org.jboss.logging#jboss-logging;${version.jboss.logging}: not found[0m
In logs I see:
Resolving org.jboss.logging#jboss-logging;3.1.1.GA
So ${version.jboss.logging} was resolving correct.
But further logs are frustrating for me:
http://repo1.maven.org/maven2/org/jboss/logging/jboss-logging/${version.jboss.logging}/jboss-logging-${version.jboss.logging}.pom
http://myRepo/repo/org/jboss/logging/jboss-logging/${version.jboss.logging}/jboss-logging-${version.jboss.logging}.pom
Why sbt tries this URLs with ${version.jboss.logging} instead of 3.1.1.GA?
Is it normal for sbt to log dependecies URL without resolving versions variables or not?
How to resolve this?
Important
My Project do not depend on org.jboss.logging directly, it is a transitive dependency.
On my local machine not on bamboo server this project compiles successfully without unresolved dependencies even if I delete whole local sbt repository.
I have manually uploaded jars to the local network repository. And it did not help.

ArtifactTransferException:

Failed to execute goal on project J2EE2: Could not resolve
dependencies for project com.example.j2ee2:J2EE2:war:0.0.1-SNAPSHOT:
The following artifacts could not be resolved: javax.jms:jms:jar:1.1,
com.sun.jdmk:jmxtools:jar:1.2.1, com.sun.jmx:jmxri:jar:1.2.1: Could
not transfer artifact javax.jms:jms:jar:1.1 from/to java.net
(https://maven-repository.dev.java.net/nonav/repository): No connector
available to access repository java.net
(https://maven-repository.dev.java.net/nonav/repository) of type
legacy using the available factories AsyncRepositoryConnectorFactory,
WagonRepositoryConnectorFactory
I've updated all my "lastUpdated" files, still I'm repeatedly getting the same error all the time. Is this error arising because I don't have setting.xml in my .m2?
Either one of the options:
1 - This repository that your configuration is trying to download the dependency doesn't exists (https://maven-repository.dev.java.net/nonav/repository)
2 - You are in a machine under a proxy and it is not configured in your maven settings.xml file (whether it is on .m2 or $MAVEN_HOME/conf )
3 - See if your eclipse is usign the maven installation or the embeded maven installation (change to maven installation)
Hope it help

Categories