Sourcesets organized in Gradle's hierarchy

In my current project, I am utilizing Gradle's SourceSets to define JavaScript sources. However, I am facing a challenge in arranging the sources in a specific order. Ideally, I would like to have something along the lines of:

javascript.source {
    custom {
        js {
            srcDir "src/js"
            include "file2.js", "file1.js"
        }
    }
}

This way, I can ensure that the files are processed in the exact sequence as declared.

While I am aware that this can be achieved using a FileTree, I believe there might be a more streamlined approach when working with SourceSets.

If achieving ordered sources through SourceSets is not feasible, what alternative method should I consider for maintaining source file dependencies?

EDIT: It is crucial for me to maintain the order of sources due to the nature of JavaScript development.

Answer №1

One approach you could consider is creating a second sourceSet in your project that includes the file file2.js, and then making your original sourceSet dependent on it. Something along these lines:

javascript.source {
    custom2 {
        js {
            srcDir "src/js2"
            include "file2.js"
        }
    }
    custom {
        js {
            srcDir "src/js"
            include "file1.js"
        }
        compileClasspath += custom2.outputs
    }
}

It's important to note that this might not be supported by the plugin you're using, but it's worth giving it a try.

In a declarative system like Gradle, specifying order usually involves declaring dependencies between different parts and allowing Gradle to handle the sequencing for you.

Answer №2

Defined as a sourceSet within gradle, it serves as a convenient way to organize and manage source and resource files without any specific order.

When dealing with the Java plugin, this concept ensures that gradle can locate the necessary source files for compiling your application seamlessly.

I'm curious about the purpose behind your request. Are there particular plugins in play? What is the ultimate goal you are aiming to achieve with the file arrangement? It seems that utilizing sourceSet may not be the solution in this scenario.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Similar to Jquery ajax, Titanium also offers a powerful tool

Currently, I have been making an API call using Titanium in the following way: var url = "http://www.appcelerator.com"; var client = Ti.Network.createHTTPClient({ // callback when data is received onload : function(e) { Ti.API.info("Re ...

Loop through different JSON objects with unique values using ng-repeat

I am facing an issue with a JSON file that contains three different objects for each area, and I need some help. Here is an example: { "gebieden":"Antwerpen", "onderwerpen":"Gemiddeld netto inkomen per belastingsplichtige", "data_2005":"15084, ...

Error in Javascript: Null Object

I have created an upload page with a PHP script for AJAX, but I'm encountering errors in Firebug. Also, the upload percentage is not being returned properly. Currently, I can only do one upload in Firefox and the script doesn't work in Chrome. H ...

Reset the checked state in React JSX to false by using a reset button

After attempting to reset selected radio buttons on this list, it seems like the change I made from {checked} to {user.checked} in input check is causing issues. This modification can be traced back to UserListElement.tsx In an effort to resolve this issu ...

Ensuring Bootstrap retains fullscreen tables while adjusting window size

I have set up a webpage containing a table and a footer. Utilizing bootstrap, I ensured that the footer remains visible while the table adjusts its height based on the remaining space on the screen. While this resizing works perfectly when the window size ...

A textarea with a height of zero is still visible

My goal is to create collapsible widgets within a side panel on my webpage. Overall, the functionality works smoothly. I am able to adjust the height of child divs to 0px with a transition, causing them to disappear. However, I have run into an issue wher ...

Navigating with Vue.js using programmatic methods while passing props

I am working with a Vue component that includes a prop called 'title' like this: <script> export default { props: ['title'], data() { return { } } } </script> After completing a specific action, I need to pro ...

Printing in Firefox is ineffective, but functions smoothly in alternative browsers

I'm currently working on customizing some content specifically for printing, so I've implemented a hook import { useState } from 'react' const usePrint = () => { const [isPrinting, setIsPrinting] = useState(false) const hand ...

When Google Chrome encounters two variables or functions with the same name, how does it respond?

I am curious what happens when Google Chrome encounters two variables with the same name. In my particular case, this issue arises in the code snippet available at this link, which is a small portion of the entire code. I am facing an issue where placing C ...

Retrieve octet-stream information from azure eventhub utilizing node.js

I am new to working with Microsoft Event Hub and I have successfully managed to read sample string data from the EventHub using a Node.js consumer. However, I now need to consume octet-stream data. Here is my code: var messageHandler = function (myIdx, ms ...

Disregarding 'zIndex' directive within JavaScript function, an image stands apart

There is an issue with the z-index values of rows of images on my webpage. Normally, the z-index values increase as you scroll further down the page. However, I want certain items to have a lower z-index than the rest (except on hover). These items are i ...

How can the threejs Box3().getSize() method be effectively utilized?

There seems to be a discrepancy in the proper usage of the Box3() getSize() method, as discussed on various platforms including stackoverflow. const geometry = new THREE.BoxGeometry( 10, 10, 10 ); const material = new THREE.MeshBasicMaterial( {color: 0x00f ...

Encountering an "invalid query parameter" error when making a find request with FeatherJS and ReactJS

Adding $show:true to the data below results in an error when making the find request. However, when I remove $show:true, everything works perfectly with no errors. The error message states: Invalid query parameter $show. I have attempted using differe ...

Can you explain the purpose of FunctionConstructor in typeScript?

As I delved into the Typescript Ecmascript source code, I stumbled upon this intriguing snippet: interface FunctionConstructor { /** * Creates a new function. * @param args A list of arguments the function accepts. */ new(...args: st ...

Dealing with side effects in react/redux: Best practices and tips

Trying to find the best way to integrate an async side-effects handler into my react/redux setup has been quite a challenge. In my react-router-driven application, all the main containers at root level are smoothly dispatching actions and receiving update ...

How can I retrieve the second letter in Materialize CSS FormSelect by using the keyboard?

On my website that utilizes materializeCSS and Jquery, I have encountered an issue with a select box containing numerous options. Typically, when using a select box, I can press a letter multiple times to cycle through options starting with that letter. ...

Utilize jQuery to select the parent checkbox and mark it as checked

Currently, I am working on a JavaScript function that will automatically check the parent checkbox if a child checkbox is checked. I am implementing this using jQuery and here is my HTML code: <ul id="ulParent" style="margin: 0; padding: 0; list- ...

The code for the Express app.get() method on the server is not being updated, although other parts of the

Recently, I encountered an issue with my node js and express server that is running on localhost. I made a change in the server code from: app.get('/', (req, res) => { res.sendFile(__dirname + '/public/index.html'); }); To: app. ...

Determining User Login Status in Laravel using jQuery

While I am familiar with the authentication verification in laravel, I am interested in learning how to verify it using jQuery. Specifically, I want to make changes to my CSS when a user is logged in. By default: body{ background: url('image.jpg ...

Consolidate array elements based on their respective categories

I am stuck with this array: [ [ 'TWENTY', 20 ], [ 'TWENTY', 20 ], [ 'TWENTY', 20 ], [ 'TEN', 10 ], [ 'TEN', 10 ], [ 'FIVE', 5 ], [ 'FIVE', 5 ], [ 'FIVE', 5 ], ...