How to fetch the latest version of a gradle task input from nexus?

Hi all,

I have a gradle task written in Java which takes some versioned artifact deployed in nexus as an input. The important part is, I always need to have the latest version of this artifact. I still couldn’t get that part working.

I tried using like this.

NamedDomainObjectProvider<Configuration> customConfigProvider =
                        c -> {
        task -> {
            Configuration customConfig = customConfigProvider.get();
                   .add(FETCH_TEXT_FILE_ZIP_TASK_CONFIG, "");

But it failed with the following error.

Could not find any matches for as no versions of are available

It works fine when I use a fixed version like

What should I do to fetch the latest version? Any ideas are really appreciated.

Assuming you are talking about a Maven repository in Nexus.
Iirc the dynamic version resolution retrieves the maven-metadata.xml for the dependency to get the list of versions.
So my guess would be that this file is missing or not accessible or not maintained properly.

Thanks for the answer. I checked the Nexus and I can see the maven-metadata.xml file with all correct versions in it.

Can you think of anything I should try from the gradle config side? Or do you think this is not an issue in the gradle side?

I tried your code with commons-lang:commons-lang:+ on mavenCentral() and it worked fine.

Alright. I unfortunately can’t try that as I can’t access mavenCentral() directly in my company network. But this helps. I will check with our dev-ops if they have disabled this from maybe at nexus level. Thanks.

1 Like