Skip to content

Conversation

bo2themax
Copy link

@bo2themax bo2themax commented Aug 26, 2025

I was trying out a Gradle package and found out that the Maven Central repository was not enough for this package, so I added a configuration option for this. It can be configured in the swift-java.config file in the following format based on https://docs.gradle.org/current/userguide/supported_repository_types.html#sec:maven-repo.:

I’m not an experienced Java/Kotlin developer, but I believe this would meet the needs of most existing packages. If future issues arise, it could be extended to support Ivy and Flat directory repositories.

{
  "repositories": [
    { "type": "maven", "url": "https://repo.mycompany.com/maven2" },
    {
      "type": "maven",
      "url": "https://repo2.mycompany.com/maven2",
      "artifactUrls": [
        "https://repo.mycompany.com/jars",
        "https://repo.mycompany.com/jars2"
      ]
    },
    { "type": "maven", "url": "https://secure.repo.com/maven2" },
    { "type": "mavenLocal", "includeGroups": ["com.example.myproject"] },
    { "type": "maven", "url": "build/repo" }, // Relative to build folder of the temporary project, better to use absolute path here, no need to add `file:` prefix
    { "type": "mavenCentral" },
    { "type": "mavenLocal" },
    { "type": "google" }
  ]
}

Note: Authentication for private repositories is not currently handled. If you need to access packages from a private repository that requires credentials, you can use Maven to download the required artifacts and then reference them via your local Maven repository in your configuration.

Alongside this PR, I’ve also added:

  • A JavaJson target to JavaDependencySampleApp.
  • A dedicated test under the SwiftJavaTests target.
  • Drafted documentation in SwiftJavaCommandLineTool.md. If you spot any incorrect wording, please let me know in the comments or add a review in the code.

Test results:

image

Sample App outputs:

image

@ktoso
Copy link
Collaborator

ktoso commented Aug 27, 2025

Looks OK but this isn't tested at all, Samples/JavaDependencySampleApp/Sources/JavaCommonsCSV/swift-java-with-custom-repositories.config Perhaps make a new target next to JavaCommonsCSV that uses this as its swift-java.config.

I'd be worried about having this accepted without the sample validating it.

@ktoso
Copy link
Collaborator

ktoso commented Aug 27, 2025

Would be good to document this in some docs as well, as otherwise it'll be hard to discover (we have md files in SwiftJavaDocumentation for docs, feel free to add one about resolving!)

@bo2themax
Copy link
Author

Looks OK but this isn't tested at all, Samples/JavaDependencySampleApp/Sources/JavaCommonsCSV/swift-java-with-custom-repositories.config Perhaps make a new target next to JavaCommonsCSV that uses this as its swift-java.config.

I'd be worried about having this accepted without the sample validating it.

Yeah make sense, I'll add the target and some related documentation later

Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, I'm a bit unsure about the added test; can we make it work with just resolve and without calling out to mvn?

@bo2themax
Copy link
Author

bo2themax commented Aug 29, 2025

Looks good overall, I'm a bit unsure about the added test; can we make it work with just resolve and without calling out to mvn?

I think so. I can only think of embedding the package inside the test resource, or maybe leveraging Gradle caches somehow.

@bo2themax
Copy link
Author

bo2themax commented Aug 29, 2025

@ktoso Beside the reviews, I also added a few more changes this time. It’s better to go through the whole diff again🙏🏻

  • Removed System dependency from OrgAndrejsJsonTests, so it can be tested on Linux.
  • Added a SimpleJavaProject to JavaRepositoryTests.
  • Wrapped the nonResolvableDependency test in a compiler check for API availability for different versions of Swift.

These four jobs are now passed both on Linux(Ubuntu 25, Swift 6.1 & 6.2) and macOS(26, Swift 6.2), so they should be able to pass on ci runners as well.
image

Jobs for SwiftJavaExtract seem to fail on the main branch too, so it still fails with this pull request

@bo2themax bo2themax requested a review from ktoso August 29, 2025 17:40
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

Successfully merging this pull request may close these issues.

2 participants