Create a self-contained application bundle.

    The bundle will contain the target classes, dependencies and resources.
192717
def bundle(self, app, results_dir):
    
    assert(isinstance(app, BundleCreate.App))

    bundle_dir = self.get_bundle_dir(app.id, results_dir)
    self.context.log.debug('creating {}'.format(os.path.relpath(bundle_dir, get_buildroot())))

    safe_mkdir(bundle_dir, clean=True)

    classpath = OrderedSet()

    # Create symlinks for both internal and external dependencies under `lib_dir`. This is
    # only needed when not creating a deployjar
    lib_dir = os.path.join(bundle_dir, self.LIBS_DIR)
    if not app.deployjar:
      os.mkdir(lib_dir)
      consolidated_classpath = self.context.products.get_data('consolidated_classpath')
      classpath.update(ClasspathProducts.create_canonical_classpath(
        consolidated_classpath,
        app.target.closure(bfs=True, **self._target_closure_kwargs),
        lib_dir,
        internal_classpath_only=False,
        excludes=app.binary.deploy_excludes,
      ))

    bundle_jar = os.path.join(bundle_dir, '{}.jar'.format(app.binary.basename))
    with self.monolithic_jar(app.binary, bundle_jar,
                             manifest_classpath=classpath) as jar:
      self.add_main_manifest_entry(jar, app.binary)

      # Make classpath complete by adding the monolithic jar.
      classpath.update([jar.path])

    if app.binary.shading_rules:
      for jar_path in classpath:
        # In case `jar_path` is a symlink, this is still safe, shaded jar will overwrite jar_path,
        # original file `jar_path` linked to remains untouched.
        # TODO run in parallel to speed up
        self.shade_jar(shading_rules=app.binary.shading_rules, jar_path=jar_path)

    self.symlink_bundles(app, bundle_dir)

    return bundle_dir
1080404
def _create_bundle(self, version):
        
        # *** Bundle entity
        if not hasattr(self, 'bundle_ent'):
            self.bundle_ent = NIDMResultsBundle(nidm_version=version['num'])

        self.bundle = ProvBundle(identifier=self.bundle_ent.id)

        self.bundle_ent.export(self.version, self.export_dir)

        # # provn export
        # self.bundle = ProvBundle(identifier=bundle_id)

        self.doc.entity(self.bundle_ent.id,
                        other_attributes=self.bundle_ent.attributes)

        # *** NIDM-Results Export Activity
        if version['num'] not in ["1.0.0", "1.1.0"]:
            if not hasattr(self, 'export_act'):
                self.export_act = NIDMResultsExport()
            self.export_act.export(self.version, self.export_dir)
            # self.doc.update(self.export_act.p)
            self.doc.activity(self.export_act.id,
                              other_attributes=self.export_act.attributes)

        # *** bundle was Generated by NIDM-Results Export Activity
        if not hasattr(self, 'export_time'):
            self.export_time = str(datetime.datetime.now().time())

        if version['num'] in ["1.0.0", "1.1.0"]:
            self.doc.wasGeneratedBy(entity=self.bundle_ent.id,
                                    time=self.export_time)
        else:
            # provn
            self.doc.wasGeneratedBy(
                entity=self.bundle_ent.id, activity=self.export_act.id,
                time=self.export_time)

        # *** NIDM-Results Exporter (Software Agent)
        if version['num'] not in ["1.0.0", "1.1.0"]:
            if not hasattr(self, 'exporter'):
                self.exporter = self._get_exporter()
            self.exporter.export(self.version, self.export_dir)
            # self.doc.update(self.exporter.p)
            self.doc.agent(self.exporter.id,
                           other_attributes=self.exporter.attributes)

            self.doc.wasAssociatedWith(self.export_act.id, self.exporter.id)
1305398
def create_basic_app(cls, bundles=None, _config_overrides=None):
        
        bundles = bundles or []
        name = bundles[-1].module_name if bundles else 'basic_app'
        app = FlaskUnchained(name, template_folder=os.path.join(
            os.path.dirname(__file__), 'templates'))

        for bundle in bundles:
            bundle.before_init_app(app)

        unchained.init_app(app, DEV, bundles, _config_overrides=_config_overrides)

        for bundle in bundles:
            bundle.after_init_app(app)

        return app
429770
protected void initBundles() {
        if (commonBundle == null) {
            Locale locale = configuration.getLocale();
            this.commonBundle = ResourceBundle.getBundle(commonBundleName, locale);
            this.docletBundle = ResourceBundle.getBundle(docletBundleName, locale);
        }
    }
592284
def bundle(self, bundle_name):
        
        if self.args.bundle or self.tcex_json.get('package', {}).get('bundle', False):
            if self.tcex_json.get('package', {}).get('bundle_packages') is not None:
                for bundle in self.tcex_json.get('package', {}).get('bundle_packages') or []:
                    bundle_name = bundle.get('name')
                    bundle_patterns = bundle.get('patterns')

                    bundle_apps = []
                    for app in self._app_packages:
                        for app_pattern in bundle_patterns:
                            p = re.compile(app_pattern, re.IGNORECASE)
                            if p.match(app):
                                bundle_apps.append(app)

                    # bundle app in zip
                    if bundle_apps:
                        self.bundle_apps(bundle_name, bundle_apps)
            else:
                self.bundle_apps(bundle_name, self._app_packages)
477192
public void createPackageContents() {
		if (isCreated) return;
		isCreated = true;

		// Create classes and their features
		documentRootEClass = createEClass(DOCUMENT_ROOT);
		createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED);
		createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
		createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION);
		createEAttribute(documentRootEClass, DOCUMENT_ROOT__BACKGROUND_COLOR);
		createEAttribute(documentRootEClass, DOCUMENT_ROOT__BORDER_COLOR);
		createEAttribute(documentRootEClass, DOCUMENT_ROOT__COLOR);

		// Create data types
		hexColorEDataType = createEDataType(HEX_COLOR);
	}
764298
function createApplication() {
  var app = connect();
  utils.merge(app, proto);
  app.request = { __proto__: req };
  app.response = { __proto__: res };
  app.init();
  return app;
}
947713
public void onCreate() {
		Bundle bundle = new Bundle();
		if (mParentDelegate != null) {
			bundle = mParentDelegate.mBundle;
		}

		onCreate(bundle);
	}
1323633
function Bundle(packages, name)
    {
        this.packages = _.map(packages, function (package) {

            if (_.isString(package)) {
                return new Package(package);
            }

            return package;
        });
        this.name = name || 'bundle';
    }
591757
public App createApp() {
        return connection.execute(new AppCreate(new App().on(Heroku.Stack.Cedar14)), apiKey);
    }
121118
def create_app():
    """"""
    app = Flask(__name__)
    app.config_from_envvar = app.config.from_envvar
    app.config_from_object = app.config.from_object
    configure_app(app)
    init_core(app)
    register_blueprints(app)
    return app
757564
def bundle
      content = @assets.map(&:content).join("\n")

      hash = JAPR::Pipeline.hash(@source, @manifest, @options)
      @assets = [JAPR::Asset.new(content, "#{@prefix}-#{hash}#{@type}")]
    end
952446
private Collection<DependencyInfo> createDependencyInfos(Collection<PhpPackage> phpPackages, Collection<DependencyInfo> dependencyInfos, Collection<String> directDependencies) {
        HashMap<DependencyInfo, Collection<String>> parentToChildMap = new HashMap<>();
        HashMap<String, DependencyInfo> packageDependencyMap = new HashMap<>();
        // collect packages data and create its dependencyInfo
        for (PhpPackage phpPackage : phpPackages) {
            DependencyInfo dependencyInfo = createDependencyInfo(phpPackage);
            if (dependencyInfo != null) {
                parentToChildMap.put(dependencyInfo, phpPackage.getPackageRequire().keySet());
                packageDependencyMap.put(phpPackage.getName(), dependencyInfo);
            } else {
                logger.debug("Didn't succeed to create dependencyInfo for {}", phpPackage.getName());
            }
        }
        if (!packageDependencyMap.isEmpty()) {
            for (String directDependency : directDependencies) {
                // create hierarchy tree
                DependencyInfo dependencyInfo = packageDependencyMap.get(directDependency);
                if (dependencyInfo != null) {
                    collectChildren(dependencyInfo, packageDependencyMap, parentToChildMap);
                    dependencyInfos.add(dependencyInfo);
                } else {
                    logger.debug("Didn't found {} in map {}", directDependency, packageDependencyMap.getClass().getName());
                }
            }
        } else {
            logger.debug("The map {} is empty ", packageDependencyMap.getClass().getName());
        }
        return dependencyInfos;
    }
756172
function compile( bundleData, bundleFile, config, callback ) {
	var baseDir = config['path'] || path.dirname(bundleFile);
	var encoder, profileEncoder = [], profileLoader = [], bundleLoader;

	// Compile stages
	var openBundle = function( cb ) {
		return function() {

			// Create encoder
			encoder = new BinaryEncoder(
					bundleFile,
					{
						'name' 			: bundleData['name'],
						'base_dir' 		: baseDir,
						'log'			: config['log'] || 0x00,
						'sparse'		: config['sparse'],
					}
				);

			// Add profiles
			for (var i=0; i<profileEncoder.length; i++) {
				encoder.addProfile( profileEncoder[i] );
			}

			// We are ready
			cb();
		}
	}

	var loadBundles = function( cb ) {
		return function() {
			// Load a bundle by specs
			bundleLoader.addBySpecs( bundleData );
			// Solve dependencies and load resources
			bundleLoader.load( cb );
		}
	}

	var compileExports = function( cb ) {
		return function() {
			// Get the bundle to encode
			var bundle = bundleLoader.bundles[ bundleData['name'] ];

			// Encode resources
			for (var k in bundle.resources) {
				encoder.encode( bundle.resources[k], k );
			}

			// Embed blobs
			for (var k in bundle.blobs) {
				encoder.embedBlob( bundle.blobs[k][0], k, bundle.blobs[k][1] );
			}

			// We are done
			cb();
		}
	}

	var closeBundle = function( cb ) {
		return function() {
			// Close & Complete
			encoder.close();
			cb();
		}
	}

	// Check for profileTable/profileLoader
	if (config['profileEncoder'] || config['profileLoader']) {

		// Check for missing arguments
		if (!config['profileEncoder']) {
			callback( "Got 'profileLoader' but missing 'profileEncoder' in the arguments" );
			return;
		}
		if (!config['profileLoader']) {
			callback( "Got 'profileEncoder' but missing 'profileLoader' in the arguments" );
			return;
		}

		// Fetch
		profileEncoder = config['profileEncoder'];
		profileLoader = config['profileLoader'];

		// Make sure it's array
		if (!(profileEncoder instanceof Array))
			profileEncoder = [ profileEncoder ];
		if (!(profileLoader instanceof Array))
			profileLoader = [ profileLoader ];

	} else {

		// Identify some important information
		var profile = config['profile'] || bundleData['profile'];
		if (!profile) {
			callback( "No jbb profile was specified!");
			return;
		}

		// Make sure it's array
		if (typeof profile === 'string')
			profile = [ profile ];

		// Require
		for (var i=0; i<profile.length; i++) {
			var pname = profile[i];
			if (pname[0] == ".") {
				profileEncoder.push( require( path.join(process.cwd(), pname, '/profile-encode') ) );
				profileLoader.push( require( path.join(process.cwd(), pname, "/profile-loader") ) );
			} else {
				profileEncoder.push( require('jbb-profile-'+pname+'/profile-encode') );
				profileLoader.push( require('jbb-profile-'+pname+"/profile-loader") );
			}
		}

	}

	// Load profile table and compiler helper
	bundleLoader = new BundlesLoader( baseDir );
	for (var i=0; i<profileLoader.length; i++) {
		bundleLoader.addProfileLoader( profileLoader[i] );
	}

	// Chained initialization of profile loaders
	var context = { 'remaining': profileLoader.length }
	var init_callback = (function() {
		if (--this.remaining == 0) {
			openBundle(
				loadBundles(
					compileExports(
						closeBundle( callback || function(){} )
						) 
					) 
			)();
		}
	}).bind(context);

	// Initialize profile compiler with the specs file
	for (var i=0; i<profileLoader.length; i++) {
		if (!profileLoader[i].initialize) {
			init_callback();
		} else {
			profileLoader[i].initialize( init_callback, bundleData );
		}
	}

}
127523
def bundle(self):
        
        ca = self
        bundle = [ca]

        while ca.parent is not None:
            bundle.append(ca.parent)
            ca = ca.parent
        return bundle
97885
public Extension createExtension(final Bundle bundle) {
		NullArgumentException.validateNotNull(bundle, "Bundle");
		if (bundle.getState() != Bundle.ACTIVE) {
			LOG.debug("Bundle is not in ACTIVE state, ignore it!");
			return null;
		}

		// Check compatibility
		Boolean canSeeServletClass = canSeeClass(bundle, Servlet.class);
		if (Boolean.FALSE.equals(canSeeServletClass)) {
			LOG.debug(
					"Ignore bundle {} which is not compatible with this extender",
					bundle);
			return null;
		}

		// Check that this is a web bundle
		String contextName = getHeader(bundle, "Web-ContextPath");
		if (contextName == null) {
			return null;
		}
		contextName = contextName.trim();
		if (contextName.startsWith("/")) {
			contextName = contextName.substring(1);
		}

		// Start web app creation
		final WebApp webApp = new WebApp();
		webApp.setDeploymentState(WebEvent.UNDEPLOYED);
		webApp.setBundle(bundle);
		webApp.setContextName(contextName);
		try {
			eventDispatcher.webEvent(webApp, WebEvent.DEPLOYING);
			parser.parse(bundle, webApp);

			String requireCapabilityHeader = ManifestUtil.getHeader(bundle,
					"Require-Capability");
			// If the header isn't present Pax-Web is able to take care of it.
			// otherwise needs support by Pax-CDI
			if (requireCapabilityHeader == null
					|| !requireCapabilityHeader.contains("osgi.extender=pax.cdi")) {
				webApp.setHasDependencies(true);
				dependencyManager.addWebApp(webApp);
			}

			// Register the web app
			synchronized (webApps) {
				webApps.put(bundle.getBundleId(), webApp);
			}

			return new SimpleExtension(bundle) {
				@Override
				public void doStart() {
					// Check if the web app has already been destroyed
					synchronized (webApps) {
						if (!webApps.containsKey(bundle.getBundleId())) {
							return;
						}
					}
					if (Optional.ofNullable(ManifestUtil.getHeader(bundle, "Webapp-Deploy")).orElse("true").equals("true")) {
	                    deploy(webApp);
	                } else {
	                    eventDispatcher.webEvent(new WebEvent(WebEvent.UNDEPLOYED,"/" + webApp.getContextName(), webApp.getBundle(),
	                            bundleContext.getBundle()));
	                }
				}

				@Override
				public void doDestroy() {
					// Flag this web app has destroyed by removing it
					// from the list
					synchronized (webApps) {
						webApps.remove(bundle.getBundleId());
					}
					dependencyManager.removeWebApp(webApp);
					undeploy(webApp);
					eventDispatcher.removeWebApp(webApp);
				}
			};
			//CHECKSTYLE:OFF
		} catch (Exception e) {
			LOG.error(
					"Error scanning web bundle " + bundle + ": "
							+ e.getMessage(), e);
			eventDispatcher.webEvent(webApp, WebEvent.FAILED, e);
			return null;
		}
		//CHECKSTYLE:ON
	}
69146
private function generateBundleBundleClass()
    {
        // add optional bundles if defined by parameter.
        if ($this->bundleAdditions !== null) {
            $this->bundleBundleGenerator->setAdditions($this->bundleAdditions);
        } else {
            $this->bundleBundleGenerator->setAdditions([]);
        }

        $this->bundleBundleGenerator->generate(
            $this->bundleBundleList,
            $this->bundleBundleNamespace,
            $this->bundleBundleClassname,
            $this->bundleBundleClassfile
        );
    }