Hoes does Copy work?

I have a Copy task that insists on copying every file from every subproject into my output folder.

task copyIt(type: Copy) {
	def projectPath = projectDir.absolutePath
    def modsDir = "${buildDir}\\Program Files\\mods"
    def pluginsDir = "${buildDir}\\Program Files\\plugins"
    def adaptersDir = "${buildDir}\\Program Files\\adapters"
    from projectPath
      into modsDir
        include '**/build/libs/mods*.jar'
      into pluginsDir
        include '/**/build/libs/*plugin.jar'
      into adaptersDir
        include '/**/build/libs/*adapter.jar'
      eachFile { file -> file.path = file.name }
}

I need to get just the jar files from my build and place them into the three separate folders.

This task gives me one folder, with the whole project in it.

Why aren’t the filters doing what the manual states they are supposed do?

Why do I only get one output folder, the last? Are the other two ignored?

I can do this in eight lines in Ant, why does Gradle make it so difficult?

So I’ll answer my own question:

My from and into variables should have been defined as “${project{Path}”, “${modsDir}”, etc.

The second error was eachfile needed to be “mods\\${file.name}”.

Apologies for the title, should have been How.

Well, also here are many things done you really really really shouldn’t do.

From not using task-configuration avoidance by doing task copyIt and thus wasting time on each and every Gradle invocation that does not run that task, over using deprecated API like buildDir, to accessing files in other projects of the build and accessing outputs of other tasks by path even if they were in the same project.

All things you really shouldn’t do with Gradle. You actively work against one of the most useful features in Gradle like avoiding unnecessary work.

So instead of being helpful and perhaps increase a newbie’s knowledge, you sit there in your ivory tower and just make judgements. I’ll not trouble you with any more questions, sorry to have wasted your time and offended your sense of superiority.

Please don’t offload your frustration into personal attacks against other people, that is not in accordance with the Gradle Code of Conduct.

I neither judged anything, nor felt my time wasted, or my sense of superiority offended. Conversations like this now are a waste of my time though. I did try to be helpful and increase your knowledge by showing you problems in your code that are very non-idiomatic and will bring you massive problems, performance drains, reliability and reproducibility problems, …

Gradle has quite extensive and good documentation and examples.
But it seems like you did not really look at any of it, just like the CoC, but just tried random things or snippets AI and the internet suggested.

I did just list some of the problems in your code and even with reasons why they are bad and also using terms with which you can research further.

I even gave you concrete code in the other thread how to idiomatically have dependencies to the jar tasks in the other projects and get the jar files for further processing.

I am just a user like you, trying to help fellow users. I’m not a paid supporter or an employee or contactee of you or anything similar.

If you don’t want proper help, fine.
If you want to use that code that seems to work for you, fine, it’s your build and you have to live with the consequences.

So please, if you want to participate in any Gradle community communication, stock to the CoC and don’t attack people trying to help you for your personal steam off.