question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DSL to customize project generation

See original GitHub issue

Right now, the only sensible way to customize project generation is to fork the library and extend or modify ProjectGenerator. We intend to completely review that API so that these customizations can be applied without forking the library.

It is foreseen that we would need to provide a model for both the build and the source code so that these customisations can be applied without reinventing the wheel. There are some initiative out there but none that support Java, Groovy and Kotlin.

With that in place, we intend to provide a contribution model where one could drop a jar that would be automatically recognized and tune generated projects according to certain criteria.

This is work in progress and this issue will be updated once we get started on the implementation. Feedback more than welcome.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:17
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
snicollcommented, Feb 6, 2019

A heads-up that we’ve made significant progress on this issue and we are about to merge a new API around project generation.

First of all, an abstraction model for the various assets of a project is provided:

  • A build abstraction with a Maven and Gradle implementations that allows to tune the build. Each implementation has a BuildWriter to turn the model into an actual build
  • A language abstraction with a Java, Groovy and Kotlin implementations, including a SourceCodeWriter for each
  • A more high-level model for textual resources, .gitignore and basic configuration files

Several reusable utilities are also available:

  • A TemplateRenderer abstraction (with a Mustache implementation) that allows to render (and cache) templates
  • Writer abstraction with support of indentation
  • Version model

The new API offers several hook points that one can use to contribute project assets:

  • ProjectContributor, a high-level hook-point to add assets to a directory structure with convenient implementations to grab resources from the classpath or elsewhere
  • Source file customizer to add annotations, methods or additional classes to a project
  • Build customizer to add dependencies, plugins or other configuration items

Each project runs in its own dedicated context and the new API provides several conditions so that customizers are only applied when that makes sense. The following example illustrates how the Gradle build can be tuned to apply the war plugin when a war packaging is requested:

@Bean
@ConditionalOnPackaging(WarPackaging.ID)
public BuildCustomizer<GradleBuild> warPluginContributor() {
	return (build) -> build.addPlugin("war");
}

Contributions can be defined in external modules (a bit similar to auto-configurations in Spring Boot) with no change to the library necessary.

We are now in the process of reviewing the existing APIs to make sure all features are properly covered.

0reactions
snicollcommented, Feb 6, 2019

@jjathman No, there’s no such initiative at the moment and that would not be in the scope of this issue anyway. We’re on Gitter if you want to chat.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build your own textual DSL with Tools from the Eclipse ...
In this tutorial we will show you how easy it is to create your own DSL with tools from the Eclipse Modeling Project...
Read more >
Using C# Source Generators to create an external DSL
The blog post looks at how to use C# Source Generators to build an external DSL to represent mathematical expressions.
Read more >
How to create custom DSL generator? #459 - Shopify/tapioca
Yes it's possible. Your DSL generator needs to inherit from Tapioca::Compilers::DSL::Base and define 2 methods:.
Read more >
Droid DSL
Generation of customized recommendation services that can be integrated with external modelling tools. Droid is composed mainly of an Eclipse Textual Domain- ...
Read more >
Domain Specific Language Customization - MagicDraw 18.5
DSL (Domain Specific Language) customization is a model-driven approach, based on UML profiling. Our modeling tool provides the ability to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found