Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declarative build syntax #1

Closed
loicrouchon opened this issue Aug 13, 2013 · 7 comments
Closed

Declarative build syntax #1

loicrouchon opened this issue Aug 13, 2013 · 7 comments
Milestone

Comments

@loicrouchon
Copy link
Member

A declarative syntax like below would be great.

Build {
    project = "My Project";
    rootPath = ".";
    Goal {
        id="compile";
        name="Compile";
        compile {
            sources = "src/";
            "module.x",
            "module.y"
        }
    }
    Goal {
        id="doc";
        name="Generate API doc";
        doc {
            sources = "src/";
            "module.x",
            "module.y"
        }
    }
    DefaultGoal {
        name = "All";
        depends("compile", "doc")
    }
} 

Main drawback is that dependencies are declared using a Goal / Task id which is just a String and so is not typesafe anymore.

I think a let keyword has been mentionned somewhere on https:/ceylon/ceylon-spec/issues but I didn't find it back.
But it could be a solution to the typesafety issue:

Build {
    project = "My Project";
    rootPath = ".";
    let compileGoal = Goal {
        id="compile";
        name="Compile";
        compile {
            sources = "src/";
            "module.x",
            "module.y"
        }
    }
    let docGoal = Goal {
        id="doc";
        name="Generate API doc";
        doc {
            sources = "src/";
            "module.x",
            "module.y"
        }
    }
    DefaultGoal {
        name = "All";
        depends(compileGoal, docGoal)
    }
} 

But as you can see, in this second example, you have to name your Goal and as an import is needed for the function to do the processing, there is a naming conflict between the compile goal and the compile function of the goal.

@loicrouchon
Copy link
Member Author

Discussion on ceylon-spec to be able to cross-reference named arguments ceylon/ceylon-spec#749 and to be able to define your own names ceylon/ceylon-spec#744

loicrouchon added a commit that referenced this issue Aug 19, 2013
loicrouchon added a commit that referenced this issue Aug 22, 2013
loicrouchon added a commit that referenced this issue Aug 22, 2013
@ghost ghost assigned loicrouchon Aug 22, 2013
@loicrouchon
Copy link
Member Author

Here is an example of what is now possible

void run() {
    String myModule = "mod";
    String myTestModule = "test.mod";
    build {
        project = "My Build Project";
        Task {
            name = "compile";
            compile {
                moduleName = myModule;
            };
        },
        Task {
            name = "compile-tests";
            compileTests {
                moduleName = myTestModule;
            };
        },
        //...
    };
}

Concerning the dependencies part, it's less sexy for the moment as we obliged to assign a name to a task outside build() function but ceylon/ceylon-spec#744 should solve this issue.

void run() {
    String myModule = "mod";
    value compileTask = Task {
        name = "compile";
        compile {
            moduleName = myModule;
        };
    };
    build {
        project = "My Build Project";
        compileTask,
        Task {
            name = "compile-run";
            runModule {
                moduleName = myModule;
                version = "0.1";
            };
            dependencies = [compileTask];
        }
        //...
    };
}

@gavinking
Copy link
Member

This looks much better! I suppose a command line arg is used to select the Task?

PS it looks like a Task here is actually more like an ANTLR "target", right?

Sent from my iPhone

On 24/08/2013, at 9:32 PM, Loic Rouchon [email protected] wrote:

Here is an example of what is now possible

void run() {
String myModule = "mod";
String myTestModule = "test.mod";
build {
project = "My Build Project";
Task {
name = "compile";
compile {
moduleName = myModule;
};
},
Task {
name = "compile-tests";
compileTests {
moduleName = myTestModule;
};
},
//...
};
}
Concerning the dependencies part, it's less sexy for the moment as we obliged to assign a name to a task outside build() function but ceylon/ceylon-spec#744 should solve this issue.

void run() {
String myModule = "mod";
value compileTask = Task {
name = "compile";
compile {
moduleName = myModule;
};
};
build {
project = "My Build Project";
compileTask,
Task {
name = "compile-run";
runModule {
moduleName = myModule;
version = "0.1";
};
dependencies = [compileTask];
}
//...
};

Reply to this email directly or view it on GitHub.

@loicrouchon
Copy link
Member Author

Yes, you select a task by command line args ceylon run mybuildmodule/1.0.0 compile
You can also put more than one task ceylon run mybuildmodule/1.0.0 compile test doc

Concerning the terminology, yes, a Task is like an Ant target
As far as I know, Ant call it a target, Maven a goal and Gradle a task.
I don't have (yet) strong feelings about Task terminology, so If you would like to discuss about it, we can open another issue for it.

@gavinking
Copy link
Member

Ok, it looks pretty good then. Feels a little strange that the build def is nested inside a run() method but I can't think why that would actually be bad, or what would be a better alternative....

Sent from my iPhone

On 25/08/2013, at 6:49 PM, Loic Rouchon [email protected] wrote:

Yes, you select a task by command line args ceylon run mybuildmodule/1.0.0 compile
You can also put more than one task ceylon run mybuildmodule/1.0.0 compile test doc

Concerning the terminology, yes, a Task is like an Ant target
As far as I know, Ant call it a target, Maven a goal and Gradle a task.
I don't have (yet) strong feelings about Task terminology, so If you would like to discuss about it, we can open another issue for it.


Reply to this email directly or view it on GitHub.

@loicrouchon
Copy link
Member Author

Well it's currently nested inside a run() function so that you can launch the build module using ceylon run

@gavinking
Copy link
Member

Yes, I understand that.

Sent from my iPhone

On 25/08/2013, at 7:08 PM, Loic Rouchon [email protected] wrote:

Well it's currently nested inside a run() function so that you can launch the build module using ceylon run


Reply to this email directly or view it on GitHub.

loicrouchon pushed a commit that referenced this issue Aug 21, 2014
Merging upstream master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants