leiningen, lein, clojure build behind proxy server with lein_tool_deps plugin - java

I am new to clojure and I am trying to build a porject on a system that is behind a proxy server.
Every lein command I run tries to fetch middleware dependencies using the :middleware [lein-tools-deps.plugin/resolve-dependencies-with-deps-edn] tool. However, whenever it tries to download depedencies stated within the deps.edn file Java throws a connection timeout while trying to connect to https://repo1.maven.org/maven2/
environment variables
http_proxy
https_proxy
no_proxy
are configured properly.
I configured /home/<user>/.m2/settings.xml to use the proxy as well
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>my-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>myproxy.....</host>
<port>XXXX</port>
<nonProxyHosts>...|*.my.domain|localhost|127.0.0.1</nonProxyHosts>
</proxy>
</proxies>
</settings>
deps.edn is
{:deps {org.clojure/clojure {:mvn/version "1.10.0"}
org.clojure/clojurescript {:mvn/version "1.10.516}
.... }
:paths ["src/cljs" "resources" "target"]
:aliases {:build {:main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]}}}
Any lein command (ex: lein deps) results in Could not transfer artifact org.clojure:clojure:pom:1.10.0 from/to central (https://repo1.maven.org/maven2/): connect timed out
However, removing :middleware from the file project.clj allows me to fetch any dependency not in defined in the plugin.
How can I get the plugin to use the http proxy?

Related

cannot create maven project

I want to create maven project but failed. I use proxy in my network. I can reach "https://repo.maven.apache.org/maven2" in browser. the error show:
Could not resolve archetype
org.apache.maven.archetypes:maven-archetype-webapp:1.0 from any of the
configured repositories. Could not resolve artifact
org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 Could not
transfer artifact
org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from/to
central (https://repo.maven.apache.org/maven2): Connect timed out
Could not transfer artifact
org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from/to
central (https://repo.maven.apache.org/maven2): Connect timed out
I already create setting.xml and put to .m2 folder. the setting.xml contains:
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>idnproxy.myproxy.asia</host>
<port>8080</port>
<username>c76266</username>
<password>Password09</password>
<nonProxyHosts>localhost|128.*.*.*|10.*.*.*|*.intranet.asia|*.group.local</nonProxyHosts>
</proxy>
</proxies>
this setting proxy, port, username and password same with setting in my browser and I can running internet. I assume that configuration is true. how to fix this problem? thanks.
It should be settings.xml , not setting.xml
Or if you do want to use this setting.xml , from command line, point maven to this xml file
mvn -s Full_PATH_TO_setting.xml install

Unable to deploy maven artifact to maven central repository using travis

I am trying to deploy maven artifact to central repository through Travis but I am facing below error:
[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:deploy (injected-nexus-deploy) on project Test-plugin: Execution injected-nexus-deploy of goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:deploy failed: Nexus connection problem to URL [https://oss.sonatype.org/ ]: 401 - Unauthorized -> [Help 1]
I have set correct username and password for sonatype account, still I am getting the same error.
Below are the files uploaded:
.travis.yml
settings.xml
Looks like your settings.xml in the .m2 folder in your home directory is not having proper authorization properties set for maven to look
I am enclosing a sample XML for your reference ..
https://maven.apache.org/settings.html
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd"> ... <servers>
<server>
<id>server001</id>
<username>my_login</username>
<password>my_password</password>
<privateKey>${user.home}/.ssh/id_dsa</privateKey>
<passphrase>some_passphrase</passphrase>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server> </servers> ... </settings>
Here is the troubleshooting guide if you are getting 404
https://support.sonatype.com/hc/en-us/articles/213464518-Troubleshooting-Artifact-Download-Failures
From the docs
SNAPSHOT look-ups, or version ranges, or unversioned dependencies (typically plugins) will trigger metadata look-up. If the version referenced by the maven-metadata.xml is not there you will get a 404.
This can usually be fixed by running rebuild metadata on the affected artifact.

How to dynamically inject properties into settings.xml in maven

I am trying to fully automate a build and, most importantly, a release using maven in travis-ci. The way I am attempting to do it it to supply the username and password commandline as properties and have them substituted in the settings.xml file. Then, when running the build, I override the location of settings.xml to be a file I checked in. Everything needed to build and release needs to be checked into the repo. It doesn't look like maven is doing the property substitution though.
Example:
settings.xml
<?xml version='1.0' encoding='UTF-8'?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'
xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>${SONATYPE_USERNAME}</username>
<password>${SONATYPE_PASSWORD}</password>
</server>
<server>
<id>sonatype-nexus-staging</id>
<username>${SONATYPE_USERNAME}</username>
<password>${SONATYPE_PASSWORD}</password>
</server>
</servers>
</settings>
build command:
mvn --settings $PWD/settings.xml -e -X -B release:prepare release:perform "-DSONATYPE_USERNAME=YYIaF/A4" "-DSONATYPE_PASSWORD=kowLPBgK+/kRiC+O96YZT1ibvxrdcKc" -Dgpg.passphrase=passphrase
These are not the actual credentials but I included the fact they have some funky characters incase that matters.
error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project foo-parent: Failed to deploy artifacts: Could not transfer artifact com.baz:foo-parent:pom:3.0.3 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/baz/foo-parent/3.0.3/foo-3.0.3.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
but if I do this the official way (.m2/settings.xml) - all is good.
Since the objective is to fully automate a release from travis-ci, if there is just a direct way to do that, I am all ears.

Maven ssh deploy using password, Permission denied

I'm trying to build a jar using maven and automatically scp it to a remote machine.
This is my pom.xml
<properties>
<deploy.username>root</deploy.username>
<deploy.host>10.10.4.10</deploy.host>
<deploy.port>22</deploy.port>
<deploy.dir>/root</deploy.dir>
</properties>
<distributionManagement>
<repository>
<id>repo1</id>
<url>scpexe://${deploy.host}:${deploy.dir}</url>
</repository>
</distributionManagement>
This is my settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>repo1</id>
<username>root</username>
<password>root</password>
</server>
</servers>
</settings>
This the error log
Caused by: org.eclipse.aether.transfer.MetadataTransferException: Could not transfer metadata com.github.rssanders3.spark:spark_quick_start:1.0-SNAPSHOT/maven-metadata.xml from/to repo1 (scpexe://10.10.4.10:/root): Exit code: 1 - Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
at org.eclipse.aether.connector.basic.MetadataTransportListener.transferFailed(MetadataTransportListener.java:43)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:222)
at org.eclipse.aether.internal.impl.DefaultDeployer.upload(DefaultDeployer.java:417)
... 28 more
Caused by: org.apache.maven.wagon.TransferFailedException: Exit code: 1 - Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
You can see the full output of maven -X in here
I'm submitting using the following command:
mvn deploy -DskipTests --settings settings.xml
The user name and and password is correct, I'm able to ssh to it use this credential. I even tried to scp a file to the remote without any problem.
I check maven debug output, it is loading the user defined settings.xml I created.
[DEBUG] Reading user settings from /Users/xuanyue/tmp/apache-spark-quickstart-project/settings.xml
And on the ssh server side, this is the only thing I get:
Feb 23 14:33:02 hadoop10 sshd[23804]: Connection closed by 192.168.100.26
I also tried replace scpexe with scp. Still not worked.
Try running it with the -X option:
mvn -X deploy -DskipTests --settings settings.xml
I suspect the problem may be to do with the user at the other side and their permissions (not necessarily file system permissions).
First you could restart sshd on your server with -v (or -vvv for full debug) and thus get more logs in your security file.
Also it looks to me you are trying to scp on a server, have you tried using the plugin org.apache.maven.wagon ?
See Mr Thivent's post: Uploading a File via SCP with Maven fails
You probably need the Maven Wagon Provider for SSH. Note that it must be added as a build extension.
<project>
...
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.10</version>
</extension>
</extensions>
</build>
...
</project>
If you have this Wagon Provider, then the failure is likely due to your using an ancient version of Maven Wagon (you mentioned version 1.0-beta-6), which might work well with matching ancient versions (but certainly won't work well with the modern maven-dist-plugin).
Beta versions of Maven Wagon SSH do not need to be used. The current version as of now is 2.10.
Likewise, I don't believe you need to include the Maven Wagon Plugin as the maven-dist-plugin doesn't use that plugin, it directly uses the more modern wagon-provider-api. You should only need the SSH Wagon extension.
Finally, you should run a remote sshd instance for testing, from the command line (so the information goes to the terminal) with enough debugging on to determine if you are reaching the test box, and if you are actually passing in valid credentials (as sshd considers them).
It is important to remember that sshd has specific configuration options which deny root logins, if they are set. If you have access to the remote sshd box, you might also want to verify the sshd settings.

Maven 3 Eclipse Kepler is it necessary to have the environment variable to work for embedded Maven?

I have installed the last version of kepler the one has the maven embedded in it
when I tried many times to create application from any archetype
I always got
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (C:\Users\onourdean\.m2\repository)
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (C:\Users\onourdean\.m2\repository)
even though:
I have deleted the repository folder inside .m2 and its created again by it self
I have downloaded an external maven and used it
I made the proxy in sittings on both the embedded and the external
any other ideas? My settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>stsproxy</host>
<port>8080</port>
<nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
</proxy>
</proxies>
<servers>
</servers>
<mirrors>
</mirrors>
<profiles>
</profiles>
</settings>
Note That:
i have tried all the soultions in the Create a Maven project in Eclipse complains "Could not resolve archetype" except making a variable for maven due to company restriction so is this variable necessary to run the embedded version?
Its seems there is a bug in the embedded version even if i use it outside of the proxy just used the external version
then use wagon-http-lightweight-2.2.jar as described in
Can access maven repository from behind proxy, need help
and its worked
I'm not sure if it's still the same with Kepler, but with earlier Eclipse (and M2E) releases this problem usually goes away if you go to Window -> Preferences -> Maven -> Installations and add your local, external Maven installation, which usually causes Eclipse to pick up the correct settings.xml file.

Categories

Resources