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

Expected behavior for * dependencies when compiling into Java #1678

Closed
1 of 4 tasks
campionfellin opened this issue May 15, 2020 · 5 comments
Closed
1 of 4 tasks

Expected behavior for * dependencies when compiling into Java #1678

campionfellin opened this issue May 15, 2020 · 5 comments
Assignees
Labels
guidance Question that needs advice or information. language/java Related to Java bindings

Comments

@campionfellin
Copy link
Contributor

❓ Guidance

Affected Languages

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)

General Information

  • JSII Version: 1.1
  • Platform: macOS Catalina

The Question

What is the expected behavior when compiling * dependencies into Java? Here's part of an example package.json:

 jsii: {
      outdir: "dist",
      targets: {
        java: {
          package: "main",
          maven: {
            groupId: "main",
            artifactId: "main"
          }
        }
      }
    },    
    dependencies: {
      "constructs": "*",
      "cdk8s": "*",
    },

This leads to my dependencies in pom.xml looking like:

  <dependency>
      <groupId>org.cdk8s</groupId>
      <artifactId>cdk8s</artifactId>
      <version>[undefined]</version>
    </dependency>
    <dependency>
      <groupId>software.constructs</groupId>
      <artifactId>constructs</artifactId>
      <version>[undefined]</version>
    </dependency>

Changing versions from * to a numbered version like 2.0.1 or 0.21.0 seems to fix the issue.

Is this expected?
Any solutions besides explicitly adding the version?

@campionfellin campionfellin added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels May 15, 2020
@SomayaB SomayaB added the language/java Related to Java bindings label May 18, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label May 18, 2020
@RomainMuller
Copy link
Contributor

How'd you model such a dependency in pom.xml?

The reason I as is because I see two ways of addressing this:

  1. Generate a valid pom.xml from this configuration (probably also for other languages)
  2. Prohibit * dependencies

I'd instinctively lean towards option 2, however I also don't like being more restrictive than needed (so if I can express * in other languages, I don't see why I'd refrain from doing it).

Generally speaking however, jsii packages are expected to adhere to semantic versioning, and having a * dependency would mean you're accepting any major version (including incompatible ones) - that doesn't sound like something you'd want to be doing?

@RomainMuller RomainMuller added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label May 19, 2020
@campionfellin
Copy link
Contributor Author

campionfellin commented May 19, 2020

I think for (1), something like this could be acceptable for maven/Java at least:

    <dependency>
      <groupId>org.cdk8s</groupId>
      <artifactId>cdk8s</artifactId>
      <version>(0.0.0,]</version>
    </dependency>

Alternatively, for (1), it looks like there are some plugins that could help (see here) but I'm not sure that's any better than just <version>(0.0.0,]</version>

(2) is also fine with me, if it can be added to the documentation somewhere!

@campionfellin
Copy link
Contributor Author

@RomainMuller either option is fine with me, but I'd prefer (1). I can work on this if you'd like

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label May 20, 2020
@RomainMuller
Copy link
Contributor

I'm happy with option (1), however as I mentioned on the PR (thanks for that by the way), I feel 0.0.0 should be included.

RomainMuller pushed a commit that referenced this issue Jun 9, 2020
)

For #1678 in case you want to go with route (1) of supporting `*` dependencies.

Signed-off-by: campionfellin <[email protected]>
@SomayaB
Copy link
Contributor

SomayaB commented Oct 7, 2020

Closing this issue since it seems to have been resolved. Feel free to reopen.

@SomayaB SomayaB closed this as completed Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information. language/java Related to Java bindings
Projects
None yet
Development

No branches or pull requests

3 participants