flatDir repositories do not support metadata files

flatDir

artifact repositories do not support metadata files (or, more exacly, only a single metadata file with name “ivy.xml”).

This is due to this code line in IvyResolver.java, which is initialized by DefaultFlatDirArtifactRepository.

My question is: Is it intended that one cannot have metadata files for flat directory repositories? And, if no (i.e. if this is not intended): Could it be made possible to configure the metadata type (POM vs Ivy)?

Yes it’s intended. If you want a real Ivy repo, you can use ‘repositories { ivy { url “file:///…” } }’.

Thank you for your answer! Maybe it’s worth adding a note to the Gradle documentation under 50.6.5 Flat directory repository, saying that it does not support metadata files?

Just for the record: I was able to achieve what I wanted using a custom maven repository instead:

‘maven { url “$projectDir/libs” }’.

Using this repository configuration, the artifact for ‘com.example:example-project:1.0.0-SNAPSHOT’ must be placed under ‘libs/com/example/example-project/1.0.0-SNAPSHOT/example-project-1.0.0-SNAPSHOT.jar’. The metadata files named ‘example-project-1.0.0-SNAPSHOT.pom’ must be placed in the same directory as the respective JAR.

If you’d like to help improve the docs, please send a pull request.

This limitation of flatDir repositories has bitten me, too. I’ve created a PR to improve the documentation in this regard: https://github.com/gradle/gradle/pull/388