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

npmInstall task defines default but makes not optional #174

Closed
Mazorius opened this issue Jun 7, 2021 · 10 comments
Closed

npmInstall task defines default but makes not optional #174

Mazorius opened this issue Jun 7, 2021 · 10 comments
Labels
workaround exists There is a workaround for this already
Milestone

Comments

@Mazorius
Copy link

Mazorius commented Jun 7, 2021

I moved to the 3.1.0 version and got the following issue:

A problem was found with the configuration of task ':npmInstall' (type 'NpmInstallTask').
  - Type 'com.github.gradle.node.npm.task.NpmInstallTask' property 'packageJsonFile' doesn't have a configured value.
    
    Reason: This property isn't marked as optional and no value has been configured.
    
    Possible solutions:
      1. Assign a value to 'packageJsonFile'.
      2. Mark property 'packageJsonFile' as optional.
    
    Please refer to https://docs.gradle.org/7.0.2/userguide/validation_problems.html#value_not_set for more details about this problem.

From your code I see that you define a default but not set the property as Optional.

Maybe the property should be an optional to use the default?

@deepy
Copy link
Member

deepy commented Jun 7, 2021

This might be an oversight on our behalf, while doing a local test I met with the same issue but I'm also not certain what the expected result of NpmInstallTask is when no package.json exists.

I think the expectation here is that if download = true and package.json does not exist, nodeSetup and npmSetup should run but npmInstall should be skipped.
Currently, if download = false and package.json is missing, nothing is run (or at least that's what happened in my local test, need to confirm this)

If that sounds good we can probably make running it conditional on whether packageJsonFile exists or not

@Mazorius
Copy link
Author

Mazorius commented Jun 7, 2021

Hi @deepy ,

I think skipping the install task on behalf of the package.json file would be a good solution.

Thanks in advance,
Ron

@deepy
Copy link
Member

deepy commented Jun 7, 2021

I'll have a look at this later, but as a workaround for now you can configure the npmInstall task and set enabled = false

@deepy deepy added the workaround exists There is a workaround for this already label Jun 7, 2021
@Mazorius
Copy link
Author

Mazorius commented Jun 7, 2021

Thanks a lot!

I created an empty react project for testing. This works for now.

@b-gyula
Copy link

b-gyula commented Feb 3, 2022

The web3j gradle plugin uses old node and solidity gradle plugins, that are only compatible with gradle version 5.x and not 6.x or even 7.x. If you want to be able to use it with at least version 6.x you need to specifically apply newer version of these plugins: node 3.1.1 and solidity 0.3.2

id "org.web3j" version '4.8.8'
id "com.github.node-gradle.node" version '3.1.1'
id "org.web3j.solidity" version '0.3.2'

@RailOuy
Copy link

RailOuy commented Jul 17, 2022

So may I ask how to configure the npmInstall task and set enabled = false?

@deepy
Copy link
Member

deepy commented Jul 17, 2022

@RailOuy tasks.named("npmInstall").configure { enabled = false }?

@RailOuy
Copy link

RailOuy commented Jul 18, 2022

@deepy thanks

@deepy
Copy link
Member

deepy commented Jul 18, 2022

Just out of curiosity, @RailOuy is your use-case to only use NodeTask or NpxTask? (i.e using a local or downloaded node to execute a script)
Because without packages.json there's a bunch of things that aren't going to work as expected (and having an empty or almost empty packages.json is legitimate)

@RailOuy
Copy link

RailOuy commented Jul 19, 2022

Just out of curiosity, @RailOuy is your use-case to only use NodeTask or NpxTask? (i.e using a local or downloaded node to execute a script) Because without packages.json there's a bunch of things that aren't going to work as expected (and having an empty or almost empty packages.json is legitimate)

No,I just want to use web3j to connect to eth node.But the tool includes the package for solidity's usage.So I just want to skip the gradle error when the project is building. @deepy

@deepy deepy added this to the 3.5 milestone Jul 19, 2022
@deepy deepy closed this as completed Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workaround exists There is a workaround for this already
Projects
None yet
Development

No branches or pull requests

4 participants