Giter Site home page Giter Site logo

factoree's Introduction

JavaEE Factory

A JavaEE oriented project factory.

TODO

  • Logo

  • Github integration? (directly create the project on github instead of downloading a zip)

  • More facets (JSF, Servlet, Asynchronism, proprietary configuration files?…​)

  • …​

Dev workflow

  • Frontend: run

mvn compile tomee-embedded:run

then develop in src/main/webapp

The website is deployed on http://localhost:8080/factorEE

  • Backend: tests use a custom JUnit runner avoiding to have to restart/redeploying anything between test (see com.github.rmannibucau.javaeefactory.test.JavaEEFactory.Runner) and com.github.rmannibucau.javaeefactory.jaxrs.ProjectFactoryResourceTest for a sample)

Before deployment/PR

Ensure the js/css modification you did still work in a plain TomEE (and not only in embedded flavor). For that just retest quickly using the instance started with:

mvn package tomee:run

The packaging is a bit longer cause it generates all js and optimize them and css before creating the war.

Adding a facet

To add a facet just implement and register com.github.rmannibucau.javaeefactory.service.facet.FacetGenerator:

@ApplicationScoped
public class MyFacet implements FacetGenerator {
    void register(@Observes final GeneratorRegistration init) { // registration (can be used to register multiple flavors of the same facet)
        init.registerFacetType(this);
    }

    @Override
    public Stream<InMemoryFile> create(final String packageBase, final Build build, final Collection<String> facets) {
        // create InMemoryFile which are file which will be included in the final zip
    }

    @Override
    public Stream<Dependency> dependencies(final Collection<String> facets) {
        // add the dependencies you need of ignore this methods
    }

    @Override
    public String readme() {
        return "A text shown in the README.adoc for this facet description";
    }

    @Override
    public String description() {
        return "A message to help users understand what it is about in the GUI";
    }

    @Override
    public String name() {
        return "A unique name qualifying this facet";
    }

    @Override
    public Category category() {
        return Category.CORE; // or TEST, feel free to add other categories if needed
    }
}

InMemoryFile

An InMemoryFile is the a structure containing a path for a file in the zip and its content. Path starts from . of the project (folder with the build file). Content can use templating (mustache) if you rely on TemplateRenderer:

@ApplicationScoped
public class MyFacet implements FacetGenerator {
    @Inject
    private TemplateRenderer tpl;

    @Override
    public Stream<InMemoryFile> create(final String packageBase, final Build build, final Collection<String> facets) {
        final Map<String, String> model = new HashMap<String, String>() {{
            put("package", packageBase);
        }};

        final String base = build.getMainJavaDirectory() + '/' + packageBase.replace('.', '/');
        return Stream.of( // create First.java and Second.java in src/main/resources/factory/my/
                new InMemoryFile(base + "/my/First.java", tpl.render("factory/my/First.java", model)),
                new InMemoryFile(base + "/my/Second.java", tpl.render("factory/my/Second.java", model))
        );
    }

    // ...
}
Tip
to build a file path you can rely on Build which contains main folders depending the build type (Maven/Gradle). facets can be used if some generation is conditional on another facet presence. Typically a test facet will check it has the ore facets before generating a test.
Note
if your facet can have dedicated tests you should integrate them in TEST facets like ApplicationComposer or Arquillian ones.

factoree's People

Contributors

rmannibucau avatar

Stargazers

Bessem Hmdi  @BessemHmidi  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.