Exemplo n.º 1
0
  def _instantiate_jvm_app(self, kwargs):
    """For JvmApp target, convert BundleAdaptor to BundleProps."""
    parse_context = ParseContext(kwargs['address'].spec_path, dict())
    bundleprops_factory = Bundle(parse_context)
    kwargs['bundles'] = [
      bundleprops_factory.create_bundle_props(bundle)
      for bundle in kwargs['bundles']
    ]

    return JvmApp(build_graph=self, **kwargs)
Exemplo n.º 2
0
    def _instantiate_jvm_app(self, kwargs):
        """For JvmApp target, convert BundleAdaptor to BundleProps."""
        parse_context = ParseContext(kwargs['address'].spec_path, dict())
        bundleprops_factory = Bundle(parse_context)
        kwargs['bundles'] = [
            bundleprops_factory.create_bundle_props(bundle)
            for bundle in kwargs['bundles']
        ]

        return JvmApp(build_graph=self, **kwargs)
Exemplo n.º 3
0
    def test_multiple_bundles(self):
        spec_path = 'src/java/org/archimedes/volume'
        stone_dense = self.create_file(
            os.path.join(spec_path, 'config/stone/dense.xml'))
        metal_dense = self.create_file(
            os.path.join(spec_path, 'config/metal/dense.xml'))
        unused = self.make_target(Address(spec_path, 'unused').spec, JvmBinary)

        self.add_to_build_file(
            'src/java/org/archimedes/volume/BUILD',
            dedent('''
      jvm_app(name='volume',
        dependencies=[':unused'],
        bundles=[
          bundle(relative_to='config', fileset='config/stone/dense.xml')
        ]
      )

      jvm_app(name='bathtub',
        dependencies=[':unused'],
        bundles=[
          bundle(fileset='config/metal/dense.xml')
        ]
      )
    '''))

        app1 = self.make_target(Address(spec_path, 'app1').spec,
                                JvmApp,
                                dependencies=[unused],
                                bundles=[
                                    Bundle(spec_path,
                                           relative_to='config',
                                           fileset='config/stone/dense.xml')
                                ])

        app2 = self.make_target(
            Address(spec_path, 'app2').spec,
            JvmApp,
            dependencies=[unused],
            bundles=[Bundle(spec_path, fileset='config/metal/dense.xml')])

        self.assertEqual(1, len(app1.bundles))
        self.assertEqual({stone_dense: 'stone/dense.xml'},
                         app1.bundles[0].filemap)

        self.assertEqual(1, len(app2.bundles))
        self.assertEqual({metal_dense: 'config/metal/dense.xml'},
                         app2.bundles[0].filemap)
Exemplo n.º 4
0
 def create_app(self, rel_path, name=None, **kwargs):
     self.create_file(os.path.join(rel_path, 'config/densities.xml'))
     return self.make_target(
         Address(rel_path, name or 'app').spec,
         JvmApp,
         bundles=[Bundle(rel_path, fileset='config/densities.xml')],
         **kwargs)
Exemplo n.º 5
0
    def test_globs_relative_to_build_root(self):
        spec_path = 'y'
        unused = self.make_target(spec_path, JvmBinary)

        globs = Globs(spec_path)
        app = self.make_target('y:app',
                               JvmApp,
                               dependencies=[unused],
                               bundles=[
                                   Bundle(spec_path,
                                          relative_to="config",
                                          fileset=globs("z/*")),
                                   Bundle(spec_path,
                                          relative_to="config",
                                          fileset=['a/b'])
                               ])

        self.assertEquals(['a/b', 'y/z/*'],
                          sorted(app.globs_relative_to_buildroot()['globs']))
Exemplo n.º 6
0
    def test_bundle_filemap_dest_bypath(self):
        spec_path = 'src/java/org/archimedes/buoyancy'
        densities = self.create_file(
            os.path.join(spec_path, 'config/densities.xml'))
        unused = self.make_target(Address(spec_path, 'unused').spec, JvmBinary)

        app = self.make_target(
            spec_path,
            JvmApp,
            dependencies=[unused],
            bundles=[Bundle(spec_path, fileset='config/densities.xml')])

        self.assertEqual(1, len(app.bundles))
        # after one big refactor, ../../../../../ snuck into this path:
        self.assertEqual({densities: 'config/densities.xml'},
                         app.bundles[0].filemap)
Exemplo n.º 7
0
    def test_bundle_filemap_dest_relative(self):
        spec_path = 'src/java/org/archimedes/crown'
        five = self.create_file(os.path.join(spec_path,
                                             'gold/config/five.xml'))
        unused = self.make_target(Address(spec_path, 'unused').spec, JvmBinary)

        app = self.make_target(spec_path,
                               JvmApp,
                               dependencies=[unused],
                               bundles=[
                                   Bundle(spec_path,
                                          relative_to='gold',
                                          fileset='gold/config/five.xml')
                               ])

        self.assertEqual(1, len(app.bundles))
        self.assertEqual({five: 'config/five.xml'}, app.bundles[0].filemap)
Exemplo n.º 8
0
    def test_bundle_filemap_dest_remap(self):
        spec_path = 'src/java/org/archimedes/crown'
        one = self.create_file(os.path.join(spec_path, 'config/one.xml'))
        unused = self.make_target(Address(spec_path, 'unused').spec, JvmBinary)

        mapper = DirectoryReMapper(os.path.join(spec_path, 'config'),
                                   'gold/config')
        app = self.make_target(spec_path,
                               JvmApp,
                               dependencies=[unused],
                               bundles=[
                                   Bundle(spec_path,
                                          mapper=mapper,
                                          fileset='config/one.xml')
                               ])

        self.assertEqual(1, len(app.bundles))
        self.assertEqual({one: 'gold/config/one.xml'}, app.bundles[0].filemap)
Exemplo n.º 9
0
    def test_bundle_filemap_dest_byglobs(self):
        spec_path = 'src/java/org/archimedes/tub'
        one = self.create_file(os.path.join(spec_path, 'config/one.xml'))
        two = self.create_file(os.path.join(spec_path, 'config/two.xml'))
        unused = self.make_target(Address(spec_path, 'unused').spec, JvmBinary)

        globs = Globs(spec_path)
        app = self.make_target(
            spec_path,
            JvmApp,
            dependencies=[unused],
            bundles=[Bundle(spec_path, fileset=globs('config/*.xml'))])

        self.assertEqual(1, len(app.bundles))
        self.assertEqual({
            one: 'config/one.xml',
            two: 'config/two.xml'
        }, app.bundles[0].filemap)
Exemplo n.º 10
0
    def test_bundle_add(self):
        spec_path = 'src/java/org/archimedes/volume'
        stone_dense = self.create_file(
            os.path.join(spec_path, 'config/stone/dense.xml'))
        metal_dense = self.create_file(
            os.path.join(spec_path, 'config/metal/dense.xml'))
        unused = self.make_target(Address(spec_path, 'unused').spec, JvmBinary)

        bundle = Bundle(
            spec_path,
            relative_to='config',
            fileset=['config/stone/dense.xml', 'config/metal/dense.xml'])
        app = self.make_target(spec_path,
                               JvmApp,
                               dependencies=[unused],
                               bundles=[bundle])

        self.assertEqual(1, len(app.bundles))
        self.assertEqual(
            {
                stone_dense: 'stone/dense.xml',
                metal_dense: 'metal/dense.xml'
            }, app.bundles[0].filemap)
Exemplo n.º 11
0
def _bundle(rel_path):
    pc = ParseContext(rel_path=rel_path, type_aliases={})
    return Bundle(pc)