<< Back to previous view |
[QB-3640] Add QuickBuild Context to API so it could be passed to groovy script
|
|
Status: | Closed |
Project: | QuickBuild |
Component/s: | None |
Affects Version/s: | 10.0.24 |
Fix Version/s: | None |
Type: | Improvement | Priority: | Major |
Reporter: | Maciej M | Assigned To: | Robin Shen |
Resolution: | Won't Fix | Votes: | 0 |
Remaining Estimate: | Unknown | Time Spent: | Unknown |
Original Estimate: | Unknown |
Description |
Hello,
I'm writing new Maven library - similar to this example https://track.pmease.com/browse/QB-3503 I need QuickBuild Context during development, so I could mock QB API and also during runtime it could be resolved in script in QuickBuild Let's present it on example: In my IDEA: -------------------------------------------------------------- It would be perfect to add Maven dependency into my Groovy/Java project like: <dependency> <groupId>com.pmease.quickbuild</groupId> <artifactId>qb-context</artifactId> <version>1.0</version> </dependency> FancyClass.java: -------------------------------------------------------------- package example.for.robin import com.pmease.quickbuild.Context public class FancyClass { Context qbContext; FancyClass(Context context){ this.qbContext = context; dummyVarGet("test"); } void dummyVarGet(String varName){ String varValue = qbContext.vars.getValue(varName) System.out.println(varValue); } } -------------------------------------------------------------- So In QB script field I'd expect something like this: -------------------------------------------------------------- groovy: @Grab("example.for.robin:Tool:1.0") import example.for.robin.FancyClass QBContext context = QBContext.getContext() // Available in QB API FancyClass fancyClass = new FancyClass(context) -------------------------------------------------------------- Best Regards Maciej |
Comments |
Comment by Maciej M [ 21/Dec/20 01:40 PM ] |
Any update? |
Comment by Robin Shen [ 21/Dec/20 02:37 PM ] |
I think it does not have much value offering this context lib simply for mocking purpose. You may include QB jar into your project directly and use some Mock (PowerMock, Michito for instance) tools to mock VariableAccessor, Configuration, or Build to have them behave as you like. |