es4x icon indicating copy to clipboard operation
es4x copied to clipboard

Maven use with different repo

Open oravecz opened this issue 4 years ago • 4 comments

When I execute es4x install, it attempts to resolve my maven dependencies, however it is using the default central repo (https://repo1.maven.org/maven2/io/reactiverse/es4x/0.11.0/es4x-0.11.0.pom). My company does not allow access to this, but rather runs their own repo.

I cave my ~/.m2/settings.xml file configured to point to our repository, but whatever process is run by ES4X is not paying attention.

Is there another method to override? Which service is initiating the maven download (e.g. I don't have mvn installed)? Are there docs for it?

oravecz avatar Apr 30 '20 13:04 oravecz

I was able to ensure that the file located at node_modules/es4x-pm/package.json does contain a reference to my companies location of es4x-pm-0.11.0.tgz.

{
  "_args": [
    [
      "[email protected]",
      "/Users/r610031/Projects/ThirdParty/eventpipe"
    ]
  ],
  "_from": "[email protected]",
  "_id": "[email protected]",
  "_inBundle": false,
  "_integrity": "sha1-GxFKVxGCIqctCHqXcNZXf/xK1hk=",
  "_location": "/es4x-pm",
  "_phantomChildren": {},
  "_requested": {
    "type": "version",
    "registry": true,
    "raw": "[email protected]",
    "name": "es4x-pm",
    "escapedName": "es4x-pm",
    "rawSpec": "0.11.0",
    "saveSpec": null,
    "fetchSpec": "0.11.0"
  },
  "_requiredBy": [
    "/"
  ],
  "_resolved": "http://company-repo.net/artifactory/api/npm/npm-virtual/es4x-pm/-/es4x-pm-0.11.0.tgz",
  "_spec": "0.11.0",
  "_where": "/Users/myproject/Projects/ThirdParty/eventpipe",
  "author": {
    "name": "Paulo Lopes",
    "email": "[email protected]"
  },
  "bin": {
    "es4x": "./bin/es4x-cli.js"
  },
  "description": "ES4X Project Manager Utilities",
  "license": "MIT",
  "name": "es4x-pm",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "version": "0.11.0"
}

When I execute npm i, this is the exception.

$ npm i

> [email protected] postinstall /Users/r610031/Projects/ThirdParty/eventpipe
> es4x install

Downloading: https://repo1.maven.org/maven2/io/reactiverse/es4x/0.11.0/es4x-0.11.0.pom
org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact io.reactiverse:es4x:pom:0.11.0 from/to central (https://repo1.maven.org/maven2/): connect timed out
	at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:52)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:369)
	at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:644)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:499)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:401)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:207)
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:240)
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:171)
	at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:200)
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:309)
	at io.reactiverse.es4x.commands.Resolver.resolve(Resolver.java:194)
	at io.reactiverse.es4x.commands.Install.installNodeModules(Install.java:312)
	at io.reactiverse.es4x.commands.Install.run(Install.java:174)
	at io.reactiverse.es4x.cli.PM.main(PM.java:37)
Caused by: java.net.SocketTimeoutException: connect timed out
	at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
	at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
	at java.base/java.net.Socket.connect(Socket.java:608)
	at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:542)
	at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:414)
	at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
	at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:326)
	at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
	at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
	at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
	at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:164)
	at org.eclipse.aether.transport.http.HttpTransporter.execute(HttpTransporter.java:290)
	at org.eclipse.aether.transport.http.HttpTransporter.implGet(HttpTransporter.java:246)
	at org.eclipse.aether.spi.connector.transport.AbstractTransporter.get(AbstractTransporter.java:67)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:457)
	at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:364)
	... 15 more
Exception in thread "main" java.lang.IllegalArgumentException: Cannot resolve artifacts [io.vertx:vertx-core:3.9.0] in maven repositories: Failed to read artifact descriptor for io.reactiverse:es4x:jar:0.11.0
	at io.reactiverse.es4x.commands.Resolver.resolve(Resolver.java:198)
	at io.reactiverse.es4x.commands.Install.installNodeModules(Install.java:312)
	at io.reactiverse.es4x.commands.Install.run(Install.java:174)
	at io.reactiverse.es4x.cli.PM.main(PM.java:37)
java
[ '-XX:+IgnoreUnrecognizedVMOptions',
  '-cp',
  '/Users/myproject/Projects/ThirdParty/eventpipe/node_modules/es4x-pm/es4x-pm-0.11.0.jar',
  'io.reactiverse.es4x.cli.PM',
  'install' ]
java process exited with code 1
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

up to date in 11.593s

oravecz avatar Apr 30 '20 13:04 oravecz

Hi,

the installer will use the default ~/.m2/repository cache but not look at settings.xml as it's not using maven (just the resolver). You can however replace the default server with:

MAVEN_REGISTRY="https://some.other.maven.mirror/" es4x install

As that will replace maven central and if you specify an url with username and password it will use it to create the authentication to the given server too.

MAVEN_REGISTRY="https://username:[email protected]:80/" es4x install

pmlopes avatar Apr 30 '20 13:04 pmlopes

maybe it can be like below, use config in package.json

{
  "name": "es4x-demo",
  "version": "1.0.0",
  "private": true,
  "description": "A barebones es4x application",
  "main": "index.js",
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@vertx/core": "3.9.4"
  },
  "devDependencies": {
    "@es4x/create": "0.13.3",
    "@vertx/unit": "3.9.4"
  },
  "scripts": {
    "postinstall": "MAVEN_REGISTRY=$npm_package_config_maven_registry es4x install",
    "start": "es4x",
    "test": "es4x test index.test.js"
  },
  "config": {
    "maven_registry": "https://mirrors.huaweicloud.com/repository/maven/"
  }
}

fantasy0v0 avatar Oct 24 '20 08:10 fantasy0v0

The issue with declaring it on the package json is that it won't be found for non root packages or else there is a conflict.

Perhaps an option like npm could be used:

es4x install --registry=https://...

Wdyt?

pmlopes avatar Oct 24 '20 18:10 pmlopes