GithubHelp home page GithubHelp logo

node-java-maven's Introduction

Build Status npm version

node-java-maven

  • Install node-java-maven

      npm install node-java-maven
    
  • Add a java key to your package.json

      {
        "java": {
          "dependencies": [
            {
              "groupId": "org.apache.lucene",
              "artifactId": "lucene-core",
              "version": "4.9.0"
            }
          ]
        }
      }
    
  • Run node-java-maven

      ./node_modules/.bin/node-java-maven
    
  • Use node-java with node-java-maven to set your classpath

      var java = require('java');
      var mvn = require('node-java-maven');
    
      mvn(function(err, mvnResults) {
        if (err) {
          return console.error('could not resolve maven dependencies', err);
        }
        mvnResults.classpath.forEach(function(c) {
          console.log('adding ' + c + ' to classpath');
          java.classpath.push(c);
        });
        
        var Version = java.import('org.apache.lucene.util.Version');
      });
    
  • Exclusions dependencies with "exclusions" property

      {
        "java": {
          "exclusions": [
            {
              "groupId": "javax.activation",
              "artifactId": "activation"
            },
            {
              "groupId": "javax.ejb",
              "artifactId": "ejb"
            },
            {
              "groupId": "javax.faces",
              "artifactId": "jsf-api"
            },
            {
              "groupId": "javax.jms",
              "artifactId": "jms"
            },
            {
              "groupId": "javax.mail",
              "artifactId": "mail"
            }
          ],
          "dependencies": [
            {
              "groupId": "org.springframework",
              "artifactId": "spring",
              "version": "2.0.6"
            }
          ]
        }
      }
    
  • Add another maven repo

      {
        "java": {
          "repositories": [
            {
              "id": "maven",
              "url": "http://example/repository/maven-public/",
              "credentials": {
                "username": "user",
                "password": "pass"
              }
            }
          ],
          "dependencies": [
            {
              "groupId": "org.apache.lucene",
              "artifactId": "lucene-core",
              "version": "4.9.0"
            }
          ]
        }
      }
    

node-java-maven's People

Contributors

admin-computing avatar basitali avatar cleiton-d avatar danielbarela avatar joeferner avatar klortho avatar maxim-mazurok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-java-maven's Issues

localRepository and debug should be configurable via package.json

package.json supports:

    "java": {
      "repositories": [
...
      ],
      "dependencies": [
...
      ]
    }

but it would be nice if you could also configure localRepository and debug:

    "java": {
      "debug": false,
      "localRepository": "./lib",
      "repositories": [
...
      ],
      "dependencies": [
...
      ]
    }

Cannot pull timestamped SNAPSHOT dependencies from remote Nexus repo

When a SNAPSHOT dependency is only available in a remote repo it fails with the error:

message: 'download failed for http://nexus.core.cvent.org:8081/nexus/content/repositories/public/com/cvent/automation/automation-starter/region_t2-SNAPSHOT/automation-starter-region_t2-SNAPSHOT.pom (package.json) [status: 404]',

image

If I these SNAPSHOTs are pulled down to my local repo it works fine because SNAPSHOTs are not timestamped in the local repo.

With Maven 3 the option to turn timestamped SNAPSHOTs off was removed so it seems it will need to parse the maven-metadata.xml to find the correct file names to download.

Could not resolve property: project.parent.version

Hello,

I'm trying to use node-java-maven with hazelcast and getting following error

resolving parent: com.hazelcast:hazelcast-root:3.4.2
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: Could not resolve property: project.parent.version
    at resolveProperty (/poc/hazelcast_nodejs/node_modules/node-java-maven/index.js:339:11)
    at resolveProperty (/poc/hazelcast_nodejs/node_modules/node-java-maven/index.js:336:16)
    at /poc/hazelcast_nodejs/node_modules/node-java-maven/index.js:322:14
    at String.replace (native)
    at resolveSubstitutions (/poc/hazelcast_nodejs/node_modules/node-java-maven/index.js:321:16)
    at resolveDependencyUnknowns (/poc/hazelcast_nodejs/node_modules/node-java-maven/index.js:316:28)
    at /poc/hazelcast_nodejs/node_modules/node-java-maven/index.js:174:11
    at Array.forEach (native)
    at processChildDependencies (/poc/hazelcast_nodejs/node_modules/node-java-maven/index.js:173:27)
    at /poc/hazelcast_nodejs/node_modules/node-java-maven/index.js:158:18

package.json

{
  "devDependencies": {
    "java": "git://github.com/joeferner/node-java.git"
  },
  "java": {
     "dependencies": [
       {
         "groupId": "com.hazelcast",
         "artifactId": "hazelcast-client",
         "version": "3.4.2"
       }
     ]
   }
}

Could you point me where is a problem?

Thank you

Error: Could not resolve unknowns: javax.inject:javax.inject:null

My package.json contains this:

  "java": {
    "dependencies": [
      {
        "groupId": "org.jboss.weld",
        "artifactId": "weld-osgi-bundle",
        "version": "1.1.4.Final"
      }
    ]
  }

and I get the following error:

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: could not resolve unknowns: javax.inject:javax.inject:null

Refer: http://search.maven.org/#artifactdetails%7Corg.jboss.weld%7Cweld-osgi-bundle%7C1.1.4.Final%7Cjar

I believe it is because the error is thrown if there is no version specified in the dependencies. I would suggest that we need not to rely on version.

Error on run.

I'm trying to use this for a build/deploy dependency on https://github.com/awslabs/aws-apigateway-importer

so i installed node-java-maven and added :

"java": {
    "dependencies":[
      {
        "groupId": "com.amazonaws",
        "artifactId":"aws-apigateway-importer",
        "version":"1.0.1"
      }
    ]
  }

To my package.json.

when i run .\node_modules\.bin\node-java-maven, i get:

...
resolving: org.apache.httpcomponents:httpclient:4.3.3
C:\Projects\MYPROJECT\node_modules\node-java-maven\index.js:352
    throw new Error("Could not resolve property: " + propertyName);
    ^

Error: Could not resolve property: project.parent.version
    at resolveProperty (C:\Projects\MYPROJECT\node_modules\node-java-maven\index.js:352:11)
    at resolveProperty (C:\Projects\MYPROJECT\node_modules\node-java-maven\index.js:349:16)
    at resolveProperty (C:\Projects\MYPROJECT\node_modules\node-java-maven\index.js:349:16)
    at C:\Projects\MYPROJECT\node_modules\node-java-maven\index.js:334:22
    at String.replace (native)
    ...

Am I missing something or is there an issue with this package?

0.0.11 regression

Hi,

I just tried updating to 0.0.11 from 0.0.9 and apparently the changes to the substitution logic broke my app. I have this dependency:

{
        "groupId": "org.apache.pdfbox",
        "artifactId": "pdfbox",
        "version": "1.8.10"
}

My program fails to start because it can't find a replacement for $project.version, which is definitely set.

Error: Could not resolve property: compat.module

Trying to add a dependency for Apache Hive:

"java": {
    "dependencies": [
      {
        "groupId": "org.apache.hive",
        "artifactId": "hive-jdbc",
        "version": "2.3.5"
      }
    ]
}

But when running ./node_modules/.bin/node-java-maven I am getting an error:

Error: Could not resolve property: compat.module
    at resolveProperty (/Users/user/project/node_modules/node-java-maven/index.js:395:11)
    at resolveProperty (/Users/user/project/node_modules/node-java-maven/index.js:392:16)
    at resolveProperty (/Users/user/project/node_modules/node-java-maven/index.js:392:16)
    at /Users/user/project/node_modules/node-java-maven/index.js:349:22
    at String.replace (<anonymous>)
    at resolveSubstitutions (/Users/user/project/node_modules/node-java-maven/index.js:339:15)
    at resolveDependencyUnknowns (/Users/user/project/node_modules/node-java-maven/index.js:326:31)
    at /Users/user/project/node_modules/node-java-maven/index.js:191:11
    at Array.forEach (<anonymous>)

Documentation on Options

Need more documentation on options. The issue is we have our own maven repository and we are not supposed to use the http://central.maven.org/maven2/.

Our repository and authentication of repository details are present in settings.xml under .m2 directory. The mvn command automatically pulls the artifacts from our repository as per defined in settings.xml.

Whereas, when I run through the node-java-maven, it always trying to fetch from http://central.maven.org/maven2/.

Usage example details required.

Here is a sample code on how I'm trying to use "node-java-maven"

#!/usr/bin/env node

const java = require('java');
const mvn = require('node-java-maven');

java.asyncOptions = {
  asyncSuffix: undefined,    
  syncSuffix: "",   
  promiseSuffix: "Promise",  
  promisify: require('util').promisify 
};

mvn(function(err, mvnResults) {
  if (err) {
    return console.error('could not resolve maven dependencies', err);
  }
  mvnResults.classpath.forEach(function(c) {
    console.log('adding ' + c + ' to classpath');
    java.classpath.push(c);
  });


// My code to work with java jars goes here. Works fine!!


});

// But any usage of the java jars outside mvn() fails. !!!

The issue here is if I need to write unit/jest tests for my functions written within mvn() they would fail because the java dependencies are valid only within mvn(). I see that mvn() executes at the very end making it impossible to refer to the java jar imports anywhere outside mvn().

Can you please share the right way to use "Node-java-maven" so that the java.classpath pushed within mvn() is available globally?

Issues with integration in Cypress

Hi There I managed to successfully use this library for a class of mine in nodejs.

However, when I integrate it in cypress the same class/code is not found.

Do you have any hints on how this can be debugged analyzed?

Problems trying to use node-java-maven for the first time.

Hi Joe. We'd like to use this package but ran into some problems. A couple are minor problems with the README.md:

  1. 'Add a java key to your pom.xml' should be 'Add a java key to your package.json.'
  2. Run node-java-maven with ./node_modules/.bin/node-java-maven doesn't work since the package.json does not declare a bin key. We're working around this at the moment by running ./node_modules/node-java-maven/bin/node-java-maven.

But we are also seeing a runtime error we hope you can help with:

  1. Running node-java-maven this way fails for us on a package we want to use (com.tinkerpop:gremlin-core:3.0.0.M7). The log contains several lines like these:
downloading http://central.maven.org/maven2/org/slf4j/slf4j-log4j12/${slf4j.version}/slf4j-log4j12-${slf4j.version}.pom
downloading http://central.maven.org/maven2/org/slf4j/jcl-over-slf4j/${slf4j.version}/jcl-over-slf4j-${slf4j.version}.pom

And then later we get errors like these:

COMPLETE
[ [Error: download failed for http://central.maven.org/maven2/org/slf4j/slf4j-log4j12/${slf4j.version}/slf4j-log4j12-${slf4j.version}.pom [status: 404]],
  [Error: download failed for http://central.maven.org/maven2/org/slf4j/jcl-over-slf4j/${slf4j.version}/jcl-over-slf4j-${slf4j.version}.pom [status: 404]],
  [Error: download failed for http://central.maven.org/maven2/xerces/xerces-impl/2.6.2/xerces-impl-2.6.2.pom [status: 404]],
  [Error: download failed for http://central.maven.org/maven2/xml-apis/xml-apis/2.6.2/xml-apis-2.6.2.pom [status: 404]],
  [Error: download failed for http://central.maven.org/maven2/javax/activation/activation/${activation-api.version}/activation-${activation-api.version}.pom [status: 404]],
  [Error: download failed for http://central.maven.org/maven2/org/slf4j/slf4j-api/${slf4j.version}/slf4j-api-${slf4j.version}.pom [status: 404]] ]

It appears that versions specified as properties aren't supported. Are you aware of this problem? Is there a workaround or an easy fix?

Thanks,
Jim

Property substitution does not always work

When two of the same property are specified in a pom file the property substitution fails to pick one of the values. This is evident in the pom file for ormlite-jdbc 4.48. This pom file also specifies the ormlite-version property as ${project.version} which fails to get substituted.

Error: Could not resolve property: project.parent.groupId

I do not know if it is a bug or is my fault but I am having this error in console:

Error: Could not resolve property: project.parent.groupId

My configuration is this:

"java": {
"repositories": [
{
"id": "computing",
"url": "http://10.32.8.163:8081/artifactory/computing/"
}
],
"dependencies": [
{
"groupId": "com.deustotech.computing",
"artifactId": "dante",
"version": "1.0.0"
}
]
}
this artifactId is working obviously in the IntelliJ. I am using the last version
of the module (0.1.0)

The dependency that is causing the problem is this (core of netlib-java): https://maven.hotlibs.com/com.googlecode.netlib-java.netlib-java/artifact/1.1

I have taken a look to the code and I have modified resolveSubstitutions function and now it works:

function resolveSubstitutions(str, pom, dependency) {
str = str.replace(/${(.*?)}/g, function(m, propertyName) {
if(propertyName == 'project.version' || propertyName == 'version') {
return pom.version;
}
/if(propertyName == 'project.parent.version') { //OLD CODE
return pom.version;
}
/
if(propertyName == 'project.parent.version') { //NEW CODE
return pom.pomXml.project.parent[0].version[0];
}
if(propertyName == 'project.parent.groupId') {
return pom.pomXml.project.parent[0].groupId[0]
}

var property = resolveProperty(propertyName, pom);
return property instanceof Array ? property.slice(-1) : property;
});
return resolveVersionRange(str, dependency);
}

Take a look please

Error when using version ranges

Hi,

I have specified the following dependency:

 "dependencies": [
      {
        "groupId": "com.tngtech.jgiven",
        "artifactId": "jgiven-html5-report",
        "version": "0.8.0"
      }
    ]

When executing node-java-maven I get the following error:

[ [Error: download failed for http://central.maven.org/maven2/junit/junit/[4.9,4.12]/junit-[4.9,4.12].pom (package.json/com.tngtech.jgiven:jgiven-html5-report:0.8.0) [status: 404]] ]

The problem seems to be that jgiven-html5-report has a dependency to JUnit with version [4.9,4.12] with scope provided.

Handling versions specified with property variables

This issue replaces #1.

node-java-maven fails if package includes property variable expressions for version numbers. See for example com.tinkerpop:gremlin-core:3.0.0.M7, which specifies dependencies on org.slf4j:slf4j-log4j12 (and others) with version strings expressed as property variables such as ${slf4j.version}.

A run on node-java-maven produces a log with notifications such as these:

downloading http://central.maven.org/maven2/org/slf4j/slf4j-log4j12/${slf4j.version}/slf4j-log4j12-${slf4j.version}.pom
downloading http://central.maven.org/maven2/org/slf4j/jcl-over-slf4j/${slf4j.version}/jcl-over-slf4j-${slf4j.version}.pom

And the fails with errors like these:

COMPLETE
[ [Error: download failed for http://central.maven.org/maven2/org/slf4j/slf4j-log4j12/${slf4j.version}/slf4j-log4j12-${slf4j.version}.pom [status: 404]],
  [Error: download failed for http://central.maven.org/maven2/org/slf4j/jcl-over-slf4j/${slf4j.version}/jcl-over-slf4j-${slf4j.version}.pom [status: 404]],

I have very little prior experience with maven, but I have been digging into this problem. It looks like the pom.xml for com.tinkerpop:gremlin-core:3.0.0.M7 doesn't define the values for properties it uses, but it references a parent:

 <parent>
        <groupId>com.tinkerpop</groupId>
        <artifactId>tinkerpop</artifactId>
        <version>3.0.0.M7</version>
 </parent>

And that parent pom defines the property values. Tracing my way through node-java-maven I see that parents are processed, so there is an opportunity to extract this value. I'll keep digging.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.