예제 #1
0
파일: doc.py 프로젝트: DikangGu/commons
  def _create_doc_target(self):
    all_sources = []
    all_deps = OrderedSet()
    for target in self.targets:
      if not self.only_provides or is_exported(target):
        for source in target.sources:
          source_path = os.path.join(self.java_src_prefix, source)
          if os.path.exists(source_path):
            all_sources.append(source_path)
          else:
            print "skipping %s" % source_path

          for jar_dep in target.jar_dependencies:
            if jar_dep.rev:
              all_deps.add(copy(jar_dep).intransitive())

    def create_meta_target():
      return JavaLibrary('pants.doc.deps',
                         all_sources,
                         provides = None,
                         dependencies = all_deps,
                         excludes = None,
                         resources = None,
                         binary_resources = None,
                         deployjar = False,
                         buildflags = None,
                         is_meta = True)

    # TODO(John Sirois): Find a better way to do_in_context when we don't care about the context
    return list(self.targets)[0].do_in_context(create_meta_target)
예제 #2
0
    def _create_doc_target(self):
        all_sources = []
        all_deps = OrderedSet()
        for target in self.targets:
            if not self.only_provides or is_exported(target):
                for source in target.sources:
                    source_path = os.path.join(self.java_src_prefix, source)
                    if os.path.exists(source_path):
                        all_sources.append(source_path)
                    else:
                        print "skipping %s" % source_path

                    for jar_dep in target.jar_dependencies:
                        if jar_dep.rev:
                            all_deps.add(copy(jar_dep).intransitive())

        def create_meta_target():
            return JavaLibrary('pants.doc.deps',
                               all_sources,
                               provides=None,
                               dependencies=all_deps,
                               excludes=None,
                               resources=None,
                               binary_resources=None,
                               deployjar=False,
                               buildflags=None,
                               is_meta=True)

        # TODO(John Sirois): Find a better way to do_in_context when we don't care about the context
        return list(self.targets)[0].do_in_context(create_meta_target)
예제 #3
0
  def _extract_java_sources_and_deps(self, targets):
    all_sources = []
    all_deps = OrderedSet()
    for target in targets:
      if (not self.only_provides or is_exported(target)) and (not is_doc(target)):
        for source in target.sources:
          source_path = os.path.join(self.java_src_prefix, source)
          if os.path.exists(source_path):
            all_sources.append(source_path)
          else:
            print("skipping %s" % source_path)

          for jar_dep in target.jar_dependencies:
            if jar_dep.rev:
              all_deps.add(copy(jar_dep).intransitive())
    return all_sources, all_deps
예제 #4
0
    def _create_artifact_data(self):
        props_by_repo = dict()

        def get_publish_properties(target):
            publish_properties = props_by_repo.get(target.provides.repo)
            if not publish_properties:
                publish_properties = Properties()
                with open(target.provides.repo.push_db) as props:
                    publish_properties.load(props)
                props_by_repo[target.provides.repo] = publish_properties
            return publish_properties

        data = {}
        for target in self.targets:
            if is_exported(target):
                props = get_publish_properties(target)
                for source in target.sources:
                    source_path = os.path.join(self.java_src_prefix, source)
                    key = '%s%%%s' % (target.provides.org,
                                      target.provides.name)
                    if os.path.exists(source_path):
                        if 'revision.major.%s' % key in props.getPropertyDict(
                        ):
                            major = props.getProperty('revision.major.%s' %
                                                      key)
                            minor = props.getProperty('revision.minor.%s' %
                                                      key)
                            patch = props.getProperty('revision.patch.%s' %
                                                      key)
                            revision = '%s.%s.%s' % (major, minor, patch)
                        else:
                            revision = 'NOT-PUBLISHED-YET'

                        data[source] = dict(
                            org=target.provides.org,
                            name=target.provides.name,
                            rev=revision,
                            artifactBaseUrl=target.provides.repo.url)

        with open(self.artifact_data_path, mode='w') as data_file:
            print >> data_file, "var artifacts = %s;" % json.dumps(
                data, sort_keys=True, indent=2)
            print >> data_file, "artifacts.title = '%s';" % self.options.title
            print >> data_file, "artifacts.publishDate = '%s';" % (
                datetime.now().strftime('%m/%d/%Y %I:%M %p'))
            print >> data_file, "artifacts.hasChangelog = %s;" % (
                'true' if self.link_changelog else 'false')
예제 #5
0
파일: doc.py 프로젝트: crnt/commons
  def _create_artifact_data(self):
    props_by_repo = dict()
    def get_publish_properties(target):
      publish_properties = props_by_repo.get(target.provides.repo)
      if not publish_properties:
        publish_properties = Properties()
        with open(target.provides.repo.push_db) as props:
          publish_properties.load(props)
        props_by_repo[target.provides.repo] = publish_properties
      return publish_properties

    data = {}
    for target in self.targets:
      if is_exported(target):
        props = get_publish_properties(target)
        for source in target.sources:
          source_path = os.path.join(self.java_src_prefix, source)
          key = '%s%%%s' % (target.provides.org, target.provides.name)
          if os.path.exists(source_path):
            if 'revision.major.%s' % key in props.getPropertyDict():
              major = props.getProperty('revision.major.%s' % key)
              minor = props.getProperty('revision.minor.%s' % key)
              patch = props.getProperty('revision.patch.%s' % key)
              revision = '%s.%s.%s' % (major, minor, patch)
            else:
              revision = 'NOT-PUBLISHED-YET'

            data[source] = dict(org = target.provides.org,
                                name = target.provides.name,
                                rev = revision,
                                artifactBaseUrl = target.provides.repo.url)

    with open(self.artifact_data_path, mode = 'w') as data_file:
      print >> data_file, "var artifacts = %s;" % json.dumps(data, sort_keys = True, indent = 2)
      print >> data_file, "artifacts.title = '%s';" % self.options.title
      print >> data_file, "artifacts.publishDate = '%s';" % (
        datetime.now().strftime('%m/%d/%Y %I:%M %p')
      )
      print >> data_file, "artifacts.hasChangelog = %s;" % (
        'true' if self.link_changelog else 'false'
      )
예제 #6
0
 def _print_provides(self, column_extractors, address):
   target = Target.get(address)
   if is_exported(target):
     return " ".join(extractor(target) for extractor in column_extractors)
예제 #7
0
def is_idl(target):
  # TODO(Phil Hom): can be changed to is_codegen when previous hackweek thrift download hacks are
  # removed
  return is_exported(target) and has_sources(target, '.thrift')