History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: QB-3640
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Robin Shen
Reporter: Maciej M
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
QuickBuild

Add QuickBuild Context to API so it could be passed to groovy script

Created: 26/Nov/20 04:26 AM   Updated: 21/Dec/20 02:37 PM
Component/s: None
Affects Version/s: 10.0.24
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown


 Description  « Hide
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


 All   Comments   Work Log   Change History      Sort Order:
Maciej M [21/Dec/20 01:40 PM]
Any update?

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.