[mchange-commons] Update to latest upstream version

Mat Booth mbooth at fedoraproject.org
Wed Jun 11 10:45:45 UTC 2014


commit 6ffbb712f4a1a9188ef276cf5aec565db8382fb5
Author: Mat Booth <mat.booth at redhat.com>
Date:   Wed Jun 11 11:45:25 2014 +0100

    Update to latest upstream version
    
    - Drop patches
    - Build with sbt and install with maven

 .gitignore                                 |    6 +
 climbing-nemesis.py                        |  244 ++++++++++++++++++++++++++++
 mchange-commons-jdbc-4.1.patch             |   23 ---
 mchange-commons-remove-weakness-test.patch |   45 -----
 mchange-commons.spec                       |   86 +++++-----
 mchange-no-tests.patch                     |   13 ++
 sources                                    |    2 +-
 7 files changed, 305 insertions(+), 114 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index f3eeb87..6b7bf4f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,7 @@
+/mchange-commons-java-mchange-commons-java-*/
 /mchange-commons-java-0.2.3.4-final.tar.gz
+/.project
+/.build-*.log
+/noarch
+/*.src.rpm
+/mchange-commons-java-0.2.7-final.tar.gz
diff --git a/climbing-nemesis.py b/climbing-nemesis.py
new file mode 100644
index 0000000..4bdd5ca
--- /dev/null
+++ b/climbing-nemesis.py
@@ -0,0 +1,244 @@
+#!/usr/bin/env python
+
+# Copyright 2013, 2014 Red Hat, Inc., and William C. Benton
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import xml.etree.ElementTree as ET
+import argparse
+import StringIO
+import re
+import subprocess
+import logging
+
+from os.path import exists as pathexists
+from os.path import realpath
+from os.path import join as pathjoin
+from os import makedirs
+from os import symlink
+from os import remove as rmfile
+from shutil import copyfile
+
+class Artifact(object):
+    def __init__(self, a, g, v):
+        self.artifact = a
+        self.group = g
+        self.version = v
+    
+    @classmethod
+    def fromCoords(k, coords):
+        g,a,v = coords.split(":")
+        return k(a, g, v)
+    
+    @classmethod
+    def fromSubtree(k, t, ns):
+        a = t.find("./%sartifactId" % ns).text
+        g = t.find("./%sgroupId" % ns).text
+        v = t.find("./%sversion" % ns).text
+        return k(a, g, v)
+    
+    def contains(self, substrings):
+        for s in substrings:
+            if s in self.artifact or s in self.group:
+                cn_debug("ignoring %r because it contains %s" % (self, s))
+                return True
+        if len(substrings) > 0:
+            cn_debug("not ignoring %r; looked for %r" % (self, substrings))
+        return False
+    
+    def __repr__(self):
+        return "%s:%s:%s" % (self.group, self.artifact, self.version)
+
+class DummyPOM(object):
+    def __init__(self, groupID=None, artifactID=None, version=None):
+        self.groupID = groupID
+        self.artifactID = artifactID
+        self.version = version
+        self.deps = []
+
+def interestingDep(dt, namespace):
+    if len(dt.findall("./%soptional" % namespace)) != 0:
+        cn_debug("ignoring optional dep %r" % Artifact.fromSubtree(dt, namespace))
+        return False
+    if [e for e in dt.findall("./%sscope" % namespace) if e.text == "test"] != []:
+        cn_debug("ignoring test dep %r" % Artifact.fromSubtree(dt, namespace))
+        return False
+    return True
+
+class POM(object):
+    def __init__(self, filename, suppliedGroupID=None, suppliedArtifactID=None, ignored_deps=[], override=None, extra_deps=[]):
+        self.filename = filename
+        self.sGroupID = suppliedGroupID
+        self.sArtifactID = suppliedArtifactID
+        self.logger = logging.getLogger("com.freevariable.climbing-nemesis")
+        self.deps = []
+        self.ignored_deps = ignored_deps
+        self.extra_deps = extra_deps
+        cn_debug("POM:  extra_deps is %r" % extra_deps)
+        self._parsePom()
+        self.claimedGroup, self.claimedArtifact  = override is not None and override or (self.groupID, self.artifactID)
+    
+    def _parsePom(self):
+        tree = ET.parse(self.filename)
+        project = tree.getroot()
+        self.logger.info("parsing POM %s", self.filename)
+        self.logger.debug("project tag is '%s'", project.tag)
+        tagmatch = re.match("[{](.*)[}].*", project.tag)
+        namespace = tagmatch and "{%s}" % tagmatch.groups()[0] or ""
+        self.logger.debug("looking for '%s'", ("./%sgroupId" % namespace))
+        groupIDtag = project.find("./%sgroupId" % namespace) 
+        if groupIDtag is None:
+            groupIDtag = project.find("./%sparent/%sgroupId" % (namespace,namespace))
+        
+        versiontag = project.find("./%sversion" % namespace)
+        if versiontag is None:
+            versiontag = project.find("./%sparent/%sversion" % (namespace,namespace))
+        self.logger.debug("group ID tag is '%s'", groupIDtag)
+        self.groupID = groupIDtag.text
+        self.artifactID = project.find("./%sartifactId" % namespace).text
+        self.version = versiontag.text
+        depTrees = project.findall(".//%sdependencies/%sdependency" % (namespace, namespace))
+        alldeps = [Artifact.fromSubtree(depTree, namespace) for depTree in depTrees if interestingDep(depTree, namespace)]
+        alldeps = [dep for dep in alldeps if not (dep.group == self.groupID and dep.artifact == self.artifactID)]
+        self.deps = [dep for dep in alldeps if not dep.contains(self.ignored_deps)] + [Artifact.fromCoords(xtra) for xtra in self.extra_deps]
+        jarmatch = re.match(".*JPP-(.*).pom", self.filename)
+        self.jarname = (jarmatch and jarmatch.groups()[0] or None)
+
+def cn_debug(*args):
+    logging.getLogger("com.freevariable.climbing-nemesis").debug(*args)
+
+def cn_info(*args):
+    logging.getLogger("com.freevariable.climbing-nemesis").info(*args)
+
+def resolveArtifact(group, artifact, pomfile=None, kind="jar", ignored_deps=[], override=None, extra_deps=[]):
+    # XXX: some error checking would be the responsible thing to do here
+    cn_debug("rA:  extra_deps is %r" % extra_deps)
+    if pomfile is None:
+        try:
+            if getFedoraRelease() > 19:
+                [pom] = subprocess.check_output(["xmvn-resolve", "%s:%s:pom:%s" % (group, artifact, kind)]).split()
+            else:
+                [pom] = subprocess.check_output(["xmvn-resolve", "%s:%s:%s" % (group, artifact, kind)]).split()
+            return POM(pom, ignored_deps=ignored_deps, override=override, extra_deps=extra_deps)
+        except:
+            return DummyPOM(group, artifact)
+    else:
+        return POM(pomfile, ignored_deps=ignored_deps, override=override, extra_deps=extra_deps)
+
+def resolveArtifacts(identifiers):
+    coords = ["%s:%s:jar" % (group, artifact) for (group, artifact) in identifiers]
+    poms =  subprocess.check_output(["xmvn-resolve"] + coords).split()
+    return [POM(pom) for pom in poms]
+
+def resolveJar(group, artifact):
+    [jar] = subprocess.check_output(["xmvn-resolve", "%s:%s:jar:jar" % (group, artifact)]).split()
+    return jar
+
+def makeIvyXmlTree(org, module, revision, status="release", meta={}, deps=[]):
+    ivy_module = ET.Element("ivy-module", {"version":"1.0", "xmlns:e":"http://ant.apache.org/ivy/extra"})
+    info = ET.SubElement(ivy_module, "info", dict({"organisation":org, "module":module, "revision":revision, "status":status}.items() + meta.items()))
+    info.text = " " # ensure a close tag
+    confs = ET.SubElement(ivy_module, "configurations")
+    for conf in ["default", "provided", "test"]:
+        ET.SubElement(confs, "conf", {"name":conf})
+    pubs = ET.SubElement(ivy_module, "publications")
+    ET.SubElement(pubs, "artifact", {"name":module, "type":"jar"})
+    if len(deps) > 0:
+        deptree = ET.SubElement(ivy_module, "dependencies")
+        for dep in deps:
+            ET.SubElement(deptree, "dependency", {"org":dep.group, "name":dep.artifact, "rev":dep.version})
+    return ET.ElementTree(ivy_module)
+
+def writeIvyXml(org, module, revision, status="release", fileobj=None, meta={}, deps=[]):
+    # XXX: handle deps!
+    if fileobj is None:
+        fileobj = StringIO.StringIO()
+    tree = makeIvyXmlTree(org, module, revision, status, meta=meta, deps=deps)
+    tree.write(fileobj, xml_declaration=True)
+    return fileobj
+
+def ivyXmlAsString(org, module, revision, status, meta={}, deps=[]):
+    return writeIvyXml(org, module, revision, status, meta=meta, deps=deps).getvalue()
+
+def placeArtifact(artifact_file, repo_dirname, org, module, revision, status="release", meta={}, deps=[], supplied_ivy_file=None, scala=None, override=None, override_dir_only=False):
+    if scala is not None:
+        module = module + "_%s" % scala
+    jarmodule = module
+    if override is not None:
+        org, module = override
+        if not override_dir_only:
+            jarmodule = module
+    repo_dir = realpath(repo_dirname)
+    artifact_dir = pathjoin(*[repo_dir] + [org] + [module, revision])
+    ivyxml_path = pathjoin(artifact_dir, "ivy.xml")
+    artifact_repo_path = pathjoin(artifact_dir, "%s-%s.jar" % (jarmodule, revision))
+    
+    if not pathexists(artifact_dir):
+        makedirs(artifact_dir)
+    
+    ivyxml_file = open(ivyxml_path, "w")
+    if supplied_ivy_file is None:
+        writeIvyXml(org, module, revision, status, ivyxml_file, meta=meta, deps=deps)
+    else:
+        copyfile(supplied_ivy_file, ivyxml_path)
+    
+    if pathexists(artifact_repo_path):
+        rmfile(artifact_repo_path)
+    
+    symlink(artifact_file, artifact_repo_path)
+
+def getFedoraRelease():
+    cmd = "rpm -q --qf %{version} fedora-release"
+    return int(subprocess.check_output(cmd.split()))
+
+def main():
+    parser = argparse.ArgumentParser(description="Place a locally-installed artifact in a custom local Ivy repository; get metadata from Maven")
+    parser.add_argument("group", metavar="GROUP", type=str, help="name of group")
+    parser.add_argument("artifact", metavar="ARTIFACT", type=str, help="name of artifact")
+    parser.add_argument("repodir", metavar="REPO", type=str, help="location for local repo")
+    parser.add_argument("--version", metavar="VERSION", type=str, help="version to advertise this artifact as, overriding Maven metadata")
+    parser.add_argument("--meta", metavar="K=V", type=str, help="extra metadata to store in ivy.xml", action='append')
+    parser.add_argument("--jarfile", metavar="JAR", type=str, help="local jar file (use instead of POM metadata")
+    parser.add_argument("--pomfile", metavar="POM", type=str, help="local pom file (use instead of xmvn-resolved one")
+    parser.add_argument("--log", metavar="LEVEL", type=str, help="logging level")
+    parser.add_argument("--ivyfile", metavar="IVY", type=str, help="supplied Ivy file (use instead of POM metadata)")
+    parser.add_argument("--scala", metavar="VERSION", type=str, help="encode given scala version in artifact name")
+    parser.add_argument("--ignore", metavar="STR", type=str, help="ignore dependencies whose artifact or group contains str", action='append')
+    parser.add_argument("--override", metavar="ORG:NAME", type=str, help="override organization and/or artifact name")
+    parser.add_argument("--override-dir-only", action='store_true', help="override organization and/or artifact name")
+    parser.add_argument("--extra-dep", metavar="ORG:NAME:VERSION", action='append', help="add the given dependencya")
+    args = parser.parse_args()
+    
+    if args.log is not None:
+        logging.basicConfig(level=getattr(logging, args.log.upper()))
+    
+    override = args.override and args.override.split(":") or None
+    cn_debug("cl: args.extra_dep is %r" % args.extra_dep)
+    extra_deps = args.extra_dep is not None and args.extra_dep or []
+    
+    pom = resolveArtifact(args.group, args.artifact, args.pomfile, "jar", ignored_deps=(args.ignore or []), override=((not args.override_dir_only) and override or None), extra_deps=extra_deps)
+    
+    if args.jarfile is None:
+        jarfile = resolveJar(pom.groupID or args.group, pom.artifactID or args.artifact)
+    else:
+        jarfile = args.jarfile
+    
+    version = (args.version or pom.version)
+    
+    meta = dict([kv.split("=") for kv in (args.meta or [])])
+    cn_debug("meta is %r" % meta)
+    
+    placeArtifact(jarfile, args.repodir, pom.groupID, pom.artifactID, version, meta=meta, deps=pom.deps, supplied_ivy_file=args.ivyfile, scala=args.scala, override=override, override_dir_only=args.override_dir_only)
+
+if __name__ == "__main__":
+    main()
diff --git a/mchange-commons.spec b/mchange-commons.spec
index 6848a66..576115c 100644
--- a/mchange-commons.spec
+++ b/mchange-commons.spec
@@ -1,34 +1,28 @@
 Name:    mchange-commons
-Version: 0.2.3.4
-Release: 5%{?dist}
+Version: 0.2.7
+Release: 1%{?dist}
 Summary: A collection of general purpose utilities for c3p0
 License: LGPLv2 or EPL
 URL:     https://github.com/swaldman/mchange-commons-java
 Group:   Development/Libraries
 
-BuildRequires: java-devel >= 1:1.6.0
-BuildRequires: java-javadoc >= 1:1.6.0
-BuildRequires: jpackage-utils
-BuildRequires: ant
-BuildRequires: junit
-BuildRequires: ant-junit
-BuildRequires: log4j
+BuildRequires: sbt
+BuildRequires: ivy-local
+BuildRequires: maven-local
+BuildRequires: log4j12
+BuildRequires: slf4j
+BuildRequires: typesafe-config
 
-Requires: jpackage-utils
-Requires: java-headless
+Source0: https://github.com/swaldman/mchange-commons-java/archive/mchange-commons-java-%{version}-final.tar.gz
+Source1: https://raw.github.com/willb/climbing-nemesis/master/climbing-nemesis.py
 
-Source0: https://github.com/swaldman/%{name}-java/archive/%{name}-java-%{version}-final.tar.gz
-
-# Patch to build with JDBC 4.1/Java 7
-Patch1: mchange-commons-jdbc-4.1.patch
-
-# Remove one of the tests that intermittently fails
-Patch2: mchange-commons-remove-weakness-test.patch
+# There is a missing dep in Fedora so cannot build tests
+Patch0:  mchange-no-tests.patch
 
 BuildArch: noarch
 
 %description
-Originally part of c3p0, %{name} is a set of general purpose
+Originally part of c3p0, mchange-commons is a set of general purpose
 utilities.
 
 %package javadoc
@@ -41,50 +35,52 @@ Group:         Documentation
 %prep
 %setup -q -n %{name}-java-%{name}-java-%{version}-final
 
-%patch1 -p0 -b .jdbc41
-%patch2 -p0 -b .testweakness
+%patch0
 
-# remove all binary bits
 find -name '*.class' -exec rm -f '{}' \;
 find -name '*.jar' -exec rm -f '{}' \;
 
+cp %{SOURCE1} .
+
+cp -pr /usr/share/sbt/ivy-local .
+
 %build
-ant \
-  -Dbuild.sysclasspath=first \
-  -Djunit.jar.file=`build-classpath junit` \
-  -Dlog4j.jar.file=`build-classpath log4j`
+# XXX: This jar has changed location, which breaks sbt -- this is a temp workaround
+rm ivy-local/org.fusesource.hawtjni/hawtjni-runtime/1.8/hawtjni-runtime-1.8.jar
+ln -s /usr/lib/java/hawtjni/hawtjni-runtime.jar ivy-local/org.fusesource.hawtjni/hawtjni-runtime/1.8/hawtjni-runtime-1.8.jar
 
-sed -i -e "s|@mchange-commons-java.version.maven@|%{version}|g" \
-  src/maven/pom.xml
+# XXX: Link deps, I understand this is a temp measure until sbt gains real xmvn integration
+python climbing-nemesis.py com.typesafe config ivy-local --version 1.0.0
+# XXX: Have to specify exact pom here in case log4j2's compat api gets resolved instead
+python climbing-nemesis.py log4j log4j ivy-local --version 1.2.14 --pom /usr/share/maven-poms/log4j12-*.pom --ignore ant --ignore junit --ignore sun.jdk
+python climbing-nemesis.py org.slf4j slf4j-api ivy-local --version 1.7.5
 
-%install
-# jar
-install -d -m 755 %{buildroot}%{_javadir}
-install -p -m 644 build/%{name}-java-%{version}.jar \
-  %{buildroot}%{_javadir}/%{name}-java.jar
+export SBT_BOOT_DIR=boot
+export SBT_IVY_DIR=ivy-local
+sbt package make-pom doc
 
-# javadocs
-install -d -m 755 %{buildroot}%{_javadocdir}/%{name}
-cp -pr build/javadoc/* %{buildroot}%{_javadocdir}/%{name}
+%mvn_artifact target/mchange-commons-java-%{version}.pom target/mchange-commons-java-%{version}.jar
 
-# pom
-install -d -m 755 %{buildroot}%{_mavenpomdir}
-install -p -m 644 src/maven/pom.xml \
-  %{buildroot}%{_mavenpomdir}/JPP-%{name}-java.pom
+%install
+%mvn_install
 
-%add_maven_depmap JPP-%{name}-java.pom %{name}-java.jar
+install -d -m 755 %{buildroot}%{_javadocdir}/%{name}
+cp -pr target/api/* %{buildroot}%{_javadocdir}/%{name}
 
-%files
+%files -f .mfiles
 %doc LICENSE*
-%{_javadir}/*
-%{_mavenpomdir}/JPP-*
-%{_mavendepmapfragdir}/%{name}
+%dir %{_javadir}/%{name}
 
 %files javadoc
 %doc LICENSE*
 %{_javadocdir}/%{name}
 
 %changelog
+* Sun Jun 08 2014 Mat Booth <mat.booth at redhat.com> - 0.2.7-1
+- Update to latest upstream version
+- Drop patches
+- Build with sbt and install with maven
+
 * Sat Jun 07 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.2.3.4-5
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
 
diff --git a/mchange-no-tests.patch b/mchange-no-tests.patch
new file mode 100644
index 0000000..5c16248
--- /dev/null
+++ b/mchange-no-tests.patch
@@ -0,0 +1,13 @@
+--- project/Build.scala.orig	2014-06-11 10:43:16.686165392 +0100
++++ project/Build.scala	2014-06-11 10:47:47.446732685 +0100
+@@ -50,9 +50,7 @@
+   val dependencies = Seq(
+     "com.typesafe" % "config" % "1.0.0" % "compile,optional",
+     "log4j" % "log4j" % "1.2.14+" % "compile,optional",
+-    "org.slf4j" % "slf4j-api" % "1.7.5+" % "compile,optional",
+-    "junit" % "junit" % "4.1+" % "test",
+-    "com.novocode" % "junit-interface" % "0.10-M3" % "test" 
++    "org.slf4j" % "slf4j-api" % "1.7.5+" % "compile,optional"
+   );
+ 
+   override lazy val settings = super.settings ++ mySettings;
diff --git a/sources b/sources
index 20d527d..9baa9c6 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-3cbe185dfa80c42b18b0185776126b71  mchange-commons-java-0.2.3.4-final.tar.gz
+c4d9438d2250b0cf3975a0836c8b2cfc  mchange-commons-java-0.2.7-final.tar.gz


More information about the scm-commits mailing list