Hi! I’m working on making a local directory availa...
# community-support
j
Hi! I’m working on making a local directory available as a source of libraries for the project, using Ivy repository. When user defines:
Copy code
dependencies {
    intellijPlatformLocal("/Users/hsz/Applications/IntelliJ IDEA <http://Ultimate.app|Ultimate.app>") // << using this helper

    intellijPlatformSources("com.jetbrains.intellij.idea:ideaIC:2023.3:sources)
}
it created an Ivy XML file:
Copy code
<ivy-module version="2.0" xmlns:m="<https://ant.apache.org/ivy/maven>">
    <configurations>
        <conf name="default" visibility="public"/>
        <conf name="sources" visibility="public"/>
    </configurations>
    <info module="IU" organisation="intellijPlatformLocal" revision="2023.3"/>
    <publications>
        <artifact conf="default" name="/Users/hsz/Applications/IntelliJ IDEA Ultimate.app/Contents" type="directory"/>
    </publications>
</ivy-module>
Then, a registered transformer processes this dependency with a
directory
artifact, like:
Copy code
@DisableCachingByDefault(because = "Not worth caching")
abstract class CollectorTransformer : TransformAction<CollectorTransformer.Parameters> {

    interface Parameters : TransformParameters {

        @get:CompileClasspath
        val sourcesClasspath: ConfigurableFileCollection
    }

    @get:Classpath
    @get:InputArtifact
    abstract val inputArtifact: Provider<FileSystemLocation>

    override fun transform(outputs: TransformOutputs) {
        val input = inputArtifact.get().asPath

        input.findSuitableJars().forEach {
            outputs.file(it)
        }

        parameters.sourcesClasspath.forEach {
            it.copyTo(outputs.file(it.name))
        }
    }
}
This basically works great, except the
sources
part. You can see I’m using
sourcesClasspath
, which (optionally) receives artifacts from the
intellijPlatformSources
configuration, and contains the
ideaIC-2023.3-sources.jar
available in another location (Gradle cache). This sources Jar is captured properly, and added to the artifacts list. The problem is that it goes to Classes, not Sources (see the screenshot). I’m not aware of sources jar path in advance, as it doesn’t belong to
/Users/hsz/Applications/IntelliJ IDEA <http://Ultimate.app|Ultimate.app>
but i.e.
/Users/hsz/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2023.2/5bcf969924aafaa0d1b4d4602ff824251b1004f6/ideaIC-2023.2-sources.jar
— and later it’s copied to
/Users/hsz/.gradle/caches/transforms-3/70f6a793757740656f4d5f680933766d/transformed/ideaIC-2023.2-sources.jar
Do you have any idea how to make this sources Jar correctly recognized?