Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage example details required. #29

Open
MrinaliniU opened this issue Jun 14, 2019 · 0 comments
Open

Usage example details required. #29

MrinaliniU opened this issue Jun 14, 2019 · 0 comments

Comments

@MrinaliniU
Copy link

MrinaliniU commented Jun 14, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant