2017 © Pedro Peláez
 

library build-bundle

Massive Art Build Bundle

image

massive/build-bundle

Massive Art Build Bundle

  • PHP
  • 8 Dependents
  • 1 Suggesters
  • 5 Forks
  • 3 Open issues
  • 5 Versions
  • 11 % Grown

The README.md

Massive Build Bundle

Test Workflow Status, (*1)

The Massive Build Bundle provides a massive:build command which runs build targets., (*2)

Targets are classes which execute arbitary code, and are registred in the dependency injection container via. tags. Targets can depend on other targets., (*3)

Virtual targets can be created in you applications configuration file. These virtual targets simply declare depenencies, enabling you to configure custom build processes., (*4)

The aim of this bundle is to provide an extensible, decoupled, way of building software project environments, especially in a development context., (*5)

If you often find youself executing several Symfony commands consecutively to establish your environment, then this bundle is for you., (*6)

This tool is not mean to replace Make or Ant or Phing. The bundle should only be used to execute build steps which are contained in the client application., (*7)

Defining targets

You can define new build targets in you applications configuration file:, (*8)

massive_build:
    targets:
        main:
            dependencies:
                target_one: ~
                target_two: ~
                target_three: ~
        quick:
            dependencies:
                target_one: ~

The above will allow you to execute:, (*9)

$ php app/console massive:build main

and:, (*10)

$ php app/console massive:build quick

Creating build classes

You create builder classes in your application / bundles. Each build class should have a specific responsiblity., (*11)

A minimal example:, (*12)

<?php

namespace My\Web\Application;

use Massive\Bundle\BuildBundle\Build\BuilderInterface;

class MyBuilder implements BuilderInterface
{
    protected $context;

    public function getName()
    {
        return 'mybuildername';
    }

    public function getDependencies()
    {
        return array();
    }

    public function build()
    {
        $application = $this->context->getApplication();
        $input = $this->context->getInput();
        $output = $this->context->getOutput();

        $output->writeln('Hello World!');
    }

    public function setContext(BuilderContext $context)
    {
        $this->context = $context;
    }
}
  • getName: Return a name for the builder.
  • getDependencies: Return the names of any builders that this builder depends on.
  • build: Execute all logic in this method
  • setContext: Called automatically by the master build command, contains the Input, Output and Application.

Registring the builder class

You can register the builder class in the dependency injection container and# then tag it with, (*13)

<service id="sulu.core.build.builder.database" class="My\Web\Application\Builder\FooBuilder">
    <tag name="massive_build.builder" />
</service>

Adding global options and customization

You can make options available to your commands (e.g. to specify that they should destroy the database, or that the name of user "x" should be set to "y")., (*14)

By taking this approach you are free to customize the build command in anyway that you like., (*15)

To so this you need to extend the massive BuildCommand and configuring the MassiveBuild bundle to use your extended class., (*16)

<?php

namespace Sulu\Bundle\CoreBundle\Command;

use Massive\Bundle\BuildBundle\Command\BuildCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class SuluBuildCommand extends BuildCommand
{
    public function configure()
    {
        parent::configure();

        // change the name of the command from "massive:build"
        $this->setName('myapp:build');

        // add an option
        $this->addOption('destroy', null, InputOption::VALUE_NONE, 'Destroy existing data');
    }
}

Launching the build

You can launch all the builders with the following command:, (*17)

$ php app/console massive:build

Launch a specific target:, (*18)

$ php app/console massive:build mytarget

If you want to see which targets are available, use the --nobuild option:, (*19)

$ php app/console massive:build --nobuild
Build Targets
=============

+---+----------+--------------------+
| # | Builder  | Deps               |
+---+----------+--------------------+
| 0 | database |                    |
| 1 | phpcr    | database           |
| 2 | fixtures | database           |
| 3 | user     | database, fixtures |
+---+----------+--------------------+

By default if you specify a specific target, the build system will build any dependencies it has, to disable this use the --nodeps option., (*20)

$ php app/console massive:build --nodeps

The Versions