Code Monkey home page Code Monkey logo

Comments (9)

gonozalviii avatar gonozalviii commented on June 12, 2024 1

I have turned off the processJandexIndex task and modified the jar task. This works fine for my use case.

from vlsi-release-plugins.

vlsi avatar vlsi commented on June 12, 2024

Unfortunately, there's no clear way of adding generated index into resources.

In Gradle, resource files are inputs to compilation tasks.
jar index takes compilation results and it creates the index.
If we add the index to resources, then it creates a circular loop.

See gradle/gradle#12774 (comment)

So the workaround is to add the file into build/resources/main directory.
Of course, it might invalidate processResources as it will find an unexpected file in build/resources/main.

On the other hand, it might be slightly better to avoid copying the index into build/resources/main, and add them only into .jaronly (e.g. configurejartask to include the index). The drawback will be that tests running withbuild/main/classesin classpath would fail to find the index viaClassLoader.getResource`.

WDYT?

from vlsi-release-plugins.

gonozalviii avatar gonozalviii commented on June 12, 2024

I had a similar idea, modifiy the jar task to include the index, but that does bring the drawback you mentioned. Modifying the processResources task doesn't work because it runs too early.
So maybe it is possible to make the "classes" task depend on the jandex tasks, and then tell the "processResources" task that it must run after the jandex task. Would that mess anything up?

from vlsi-release-plugins.

gonozalviii avatar gonozalviii commented on June 12, 2024

Would adding the "build/jandex/jandexMain" dir as a resource dir to the source set solve the testing issue?

from vlsi-release-plugins.

vlsi avatar vlsi commented on June 12, 2024

If processJandexIndex removes other files from build/resources/..., then I should probably use a different class for processJandexIndex itself. E.g. make it a regular sync task that copies only a single index file. Then it shouldn't remove other files.

The drawback would be it might trigger re-execution of processResources, which, I guess, might be acceptable.

from vlsi-release-plugins.

vlsi avatar vlsi commented on June 12, 2024

Would adding the "build/jandex/jandexMain" dir as a resource dir to the source set solve the testing issue?

The issue is that Gradle assumes all resource directories are inputs for compileJava tasks, so it would go wild when it starts compileJava and sees no files in build/jandex/jandexMain. On second execution, it will detect the previously built index, and it would trigger re-compilation.

from vlsi-release-plugins.

gonozalviii avatar gonozalviii commented on June 12, 2024

Are you sure about that? I don't think compileJava does anything with the resources.

from vlsi-release-plugins.

vlsi avatar vlsi commented on June 12, 2024

I have not tried that.

from vlsi-release-plugins.

dgeissl avatar dgeissl commented on June 12, 2024

processResources is not by default a requirement for the compileClasses task see https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_tasks
But there may actually be some folks who configured in in their builds to be this way, depends if you'd like to take the rist of a circular dependency for some projects or not.

I also have to contradict the statement that messing around with another tasks output may be acceptable. Newer gradle versions specifically enforce getting rid of such behavior up to the point the plugin won't work anymore. It also destroys the whole build avoidance gradle is so proud of.

Currently I think the best option is to customize the jar task to include the index file, also declaring a dependency on the index task.

If you need the index in your tests add the output folder of the main SourceSet to your test/resources (and a dependency for the processTestResources). Of course if you build a jar of your tests you'll have to make sure the index from the main is replaced with your test classes index...

from vlsi-release-plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.