8

Basically what I've got is a few steps involving a 3rd party compiler.

  1. Compile the Java classes.
  2. Transform some xls files to drl's.
  3. Call drools package builder and build the last file with all previously built files in the class path.

If I call this:

project.configurations.compile.add(...) 

I get:

UnsupportedOperationException: Configuration ':rules:wnp-productmessagerules:compile' 
does not allow modification.

Edit: I've just learned that I can use

artifacts {
 someConfig someTask
}

...to add the output of a task to a configuration. Now I just need to pick the right task and then figure out how to relate the configuration to my custom task. Assumes that it's configurations that affect classpaths.

user447607
  • 5,149
  • 13
  • 33
  • 55
  • Shouldn't you be adding the generated/transformed files to sourceset? – RaGe Jan 19 '16 at 06:30
  • 3rd party compiler is written in Java so I don't think that will help. Am I wrong? I suppose I could be. – user447607 Jan 19 '16 at 14:18
  • in Step1, what are you transforming? Source files or compiled class files? – RaGe Jan 19 '16 at 16:40
  • try `configurations.compile.getDependencies().add(...);` – RaGe Jan 21 '16 at 15:40
  • I finally got around to trying this. I'm afraid it didn't work. Same error. – user447607 Jan 26 '16 at 20:35
  • shouldn't you get a slightly different error? In the new line, you're attempting to modify a `DependencySet` returned by getDependencies and not a configuration. – RaGe Jan 26 '16 at 20:49
  • Well, yes. But it amounts to something very similar. You can't change it once it's set. I've looked at the legacy code and I see that it's just including them in the class path. Trying to see if I can arrange that. – user447607 Jan 26 '16 at 21:15
  • I'm not familiar with drools, but you could try making a new drools config that inherits from the project's compile config. And then add on to the new config what you need to before passing to drools package builder. – Aarjav Jan 27 '16 at 23:40
  • @Aarjav I'll try that. Here is a simple plug-in that may provide some clues. I'm not convinced it does exactly what I need it to though and I guess I'm still a bit to raw to be able to extract those clues myself as I've been looking at it for a while now. https://github.com/loosebits/drools-compiler-plugin – user447607 Jan 28 '16 at 14:29
  • So you have 3 tasks to do. Each task will take some kind of input and creates some kind of output. Can't you just use `task3.configurations.foo { task2.outputs }`, and then use `configurations.foo.asPath` as your classpath within `task3`? – Michael Schaefers Jan 29 '16 at 14:52
  • Can you show your task where you're calling drools package builder? – RaGe Jan 29 '16 at 17:59
  • I've rewritten it as a plugin. It's basically the same as loosebits but I keep getting resolution errors despite the fact that I've added literally all the libs to the classpath. IDK what is wrong and at this point I've been directed to use maven. :-( – user447607 Jan 29 '16 at 20:34

1 Answers1

0

So the answer to this question seems to be that you can't do it in a plain old task but you can do it in a plug-in. In short, you have to re-write your task as a plug-in. Others are invited to comment before I accept this as an answer.

user447607
  • 5,149
  • 13
  • 33
  • 55