예제 #1
0
    def test_merge5(self):
        a = Artifact.from_mvn_str("g1:a1:war::")
        b = Artifact.from_mvn_str("g1:a1:v1")
        a.merge_with(b)

        self.assertEqual(a.groupId, "g1")
        self.assertEqual(a.artifactId, "a1")
        self.assertEqual(a.extension, "war")
        self.assertEqual(a.classifier, "")
        self.assertEqual(a.version, "")
예제 #2
0
    def test_merge5(self):
        a = Artifact.from_mvn_str("g1:a1:war::")
        b = Artifact.from_mvn_str("g1:a1:v1")
        a.merge_with(b)

        self.assertEqual(a.groupId, "g1")
        self.assertEqual(a.artifactId, "a1")
        self.assertEqual(a.extension, "war")
        self.assertEqual(a.classifier, "")
        self.assertEqual(a.version, "")
예제 #3
0
    def test_merge3(self):
        # different artifacts won't be merged
        a = Artifact.from_mvn_str("g1:a1:v1")
        b = Artifact.from_mvn_str("g2:a2:e2::")
        a.merge_with(b)

        self.assertEqual(a.groupId, "g1")
        self.assertEqual(a.artifactId, "a1")
        self.assertEqual(a.extension, "jar")
        self.assertEqual(a.classifier, "")
        self.assertEqual(a.version, "v1")
예제 #4
0
    def test_merge3(self):
        # different artifacts won't be merged
        a = Artifact.from_mvn_str("g1:a1:v1")
        b = Artifact.from_mvn_str("g2:a2:e2::")
        a.merge_with(b)

        self.assertEqual(a.groupId, "g1")
        self.assertEqual(a.artifactId, "a1")
        self.assertEqual(a.extension, "jar")
        self.assertEqual(a.classifier, "")
        self.assertEqual(a.version, "v1")
예제 #5
0
    def from_mvn_str(cls, mvn_str):
        a = Artifact.from_mvn_str(mvn_str)

        return cls(a.groupId,
                   a.artifactId,
                   extension=a.extension,
                   classifier=a.classifier)
예제 #6
0
 def test_from_mvn_str_full(self):
     a = Artifact.from_mvn_str("g:a:e:c:v")
     self.assertEqual(a.groupId, "g")
     self.assertEqual(a.artifactId, "a")
     self.assertEqual(a.extension, "e")
     self.assertEqual(a.classifier, "c")
     self.assertEqual(a.version, "v")
예제 #7
0
 def test_from_mvn_str_gac(self):
     a = Artifact.from_mvn_str("g:a::c:")
     self.assertEqual(a.groupId, "g")
     self.assertEqual(a.artifactId, "a")
     self.assertEqual(a.extension, "jar")
     self.assertEqual(a.classifier, "c")
     self.assertEqual(a.version, "")
예제 #8
0
 def test_from_mvn_str_full(self):
     a = Artifact.from_mvn_str("g:a:e:c:v")
     self.assertEqual(a.groupId, "g")
     self.assertEqual(a.artifactId, "a")
     self.assertEqual(a.extension, "e")
     self.assertEqual(a.classifier, "c")
     self.assertEqual(a.version, "v")
예제 #9
0
 def test_from_mvn_str_gac(self):
     a = Artifact.from_mvn_str("g:a::c:")
     self.assertEqual(a.groupId, "g")
     self.assertEqual(a.artifactId, "a")
     self.assertEqual(a.extension, "jar")
     self.assertEqual(a.classifier, "c")
     self.assertEqual(a.version, "")
예제 #10
0
def install_maven_artifact(artifact_spec):
    artifact = Artifact.from_mvn_str(artifact_spec)
    try:
        install_artifact(artifact.get_rpm_str(compat_ver=artifact.version))
    except InstallationException:
        if not artifact.version:
            raise
        install_artifact(artifact.get_rpm_str())
예제 #11
0
    def test_interpolation2(self):
        a = Artifact.from_mvn_str("${gid}:a1:${v.major}.${v.minor}")
        props = {"gid": "g1", "v.major": "4", "v.minor": "11"}
        res = a.interpolate(props)

        self.assertEqual(len(res), 0)
        self.assertEqual(a.groupId, "g1")
        self.assertEqual(a.artifactId, "a1")
        self.assertEqual(a.extension, "jar")
        self.assertEqual(a.classifier, "")
        self.assertEqual(a.version, "4.11")
예제 #12
0
    def test_interpolation2(self):
        a = Artifact.from_mvn_str("${gid}:a1:${v.major}.${v.minor}")
        props = {"gid": "g1", "v.major": "4", "v.minor": "11"}
        res = a.interpolate(props)

        self.assertEqual(len(res), 0)
        self.assertEqual(a.groupId, "g1")
        self.assertEqual(a.artifactId, "a1")
        self.assertEqual(a.extension, "jar")
        self.assertEqual(a.classifier, "")
        self.assertEqual(a.version, "4.11")
예제 #13
0
    def test_interpolation3(self):
        a = Artifact.from_mvn_str("${gid}:a1")
        props = {"v.minor": "11"}
        res = a.interpolate(props)

        self.assertEqual(len(res), 1)
        self.assertEqual(res[0], "gid")
        self.assertEqual(a.groupId, "${gid}")
        self.assertEqual(a.artifactId, "a1")
        self.assertEqual(a.extension, "jar")
        self.assertEqual(a.classifier, "")
        self.assertEqual(a.version, "")
예제 #14
0
    def test_interpolation3(self):
        a = Artifact.from_mvn_str("${gid}:a1")
        props = {"v.minor": "11"}
        res = a.interpolate(props)

        self.assertEqual(len(res), 1)
        self.assertEqual(res[0], "gid")
        self.assertEqual(a.groupId, "${gid}")
        self.assertEqual(a.artifactId, "a1")
        self.assertEqual(a.extension, "jar")
        self.assertEqual(a.classifier, "")
        self.assertEqual(a.version, "")
예제 #15
0
    OptionParser.format_epilog = lambda self, formatter: self.epilog
    parser = OptionParser(usage=usage,
                        epilog=epilog)
    parser.add_option("--skip-dependencies", action="store_true", default=False,
                      help="skip dependencies section in resulting metadata")
    parser.add_option("-D", action="append", type="str",
                      help="add artifact property", metavar="property=value")

    sys.argv = args_to_unicode(sys.argv)

    (options, args) = parser.parse_args()
    if len(args) < 1:
        parser.error("At least 1 argument is required")

    try:
        uart = Artifact.from_mvn_str(args[0])
        uart.validate(allow_backref=False)
        if len(args) == 1:
            parser.error("When using artifact specification artifact path must be "
                         "provided")
        if not (uart.groupId and uart.artifactId and uart.version):
            parser.error("Defined artifact has to include at least groupId, "
                         "artifactId and version")
    except (ArtifactFormatException):
        if is_it_ivy_file(args[0]):
            uart = IvyFile(args[0])
        else:
            # it should be good old POM file
            uart = POM(args[0])
        pom_path = args[0]
    else:
예제 #16
0
        elif options.xmvn_javadoc:
            mvn_args.append("org.fedoraproject.xmvn:xmvn-mojo:javadoc")
        else:
            mvn_args.append(
                "org.apache.maven.plugins:maven-javadoc-plugin:aggregate")

    if not options.gradle:
        # Build dependency generation for Gradle is not yet implemented in XMvn
        mvn_args.append("org.fedoraproject.xmvn:xmvn-mojo:builddep")

    if options.goal_after:
        mvn_args.extend(options.goal_after)

    if options.singleton:
        # make sure we don't install artifacts with non-empty classifiers
        xc.add_package_mapping(Artifact.from_mvn_str(":::*?:"),
                               "__noinstall",
                               optional=True)
        xc.add_package_mapping(Artifact.from_mvn_str(":{*}"), "@1")

    print("Executing:", " ".join(mvn_args), file=sys.stderr)
    print(mvn_args, file=sys.stderr)
    sys.stderr.flush()
    p = subprocess.Popen(" ".join(mvn_args), shell=True, env=os.environ)
    p.wait()

    subprocess.Popen("""
        if [ -f .xmvn-builddep ]; then
            echo -----BEGIN MAVEN BUILD DEPENDENCIES-----
            gzip -9nc <.xmvn-builddep | base64
            echo -----END MAVEN BUILD DEPENDENCIES-----
예제 #17
0
            pass
        elif options.xmvn_javadoc:
            mvn_args.append("org.fedoraproject.xmvn:xmvn-mojo:javadoc")
        else:
            mvn_args.append("org.apache.maven.plugins:maven-javadoc-plugin:aggregate")

    if not options.gradle:
        # Build dependency generation for Gradle is not yet implemented in XMvn
        mvn_args.append("org.fedoraproject.xmvn:xmvn-mojo:builddep")

    if options.goal_after:
        mvn_args.extend(options.goal_after)

    if options.singleton:
        # make sure we don't install artifacts with non-empty classifiers
        xc.add_package_mapping(Artifact.from_mvn_str(":::*?:"), "__noinstall",
                               optional=True)
        xc.add_package_mapping(Artifact.from_mvn_str(":{*}"), "@1")

    print("Executing:", " ".join(mvn_args), file=sys.stderr)
    print(mvn_args, file=sys.stderr)
    sys.stderr.flush()
    p = subprocess.Popen(" ".join(mvn_args), shell=True, env=os.environ)
    p.wait()

    subprocess.Popen("""
        if [ -f .xmvn-builddep ]; then
            echo -----BEGIN MAVEN BUILD DEPENDENCIES-----
            gzip -9nc <.xmvn-builddep | base64
            echo -----END MAVEN BUILD DEPENDENCIES-----
        fi
예제 #18
0
      groupId:artifactId[:extension[:classifier]][:version]

Wildcards (*) and empty parts in specifications are allowed (treated as wildcard).

Examples of valid specifications:
commons-lang:commons-lang:1.2
commons-lang:commons-lang:war:
commons-lang:commons-lang:war:test-jar:
commons-lang:commons-lang:war:test-jar:3.1
*:commons-lang (equivalent to ':commons-lang')
"""

if __name__ == "__main__":
    parser = SaneParser(usage=usage, epilog=epilog)
    sys.argv = args_to_unicode(sys.argv)

    (options, args) = parser.parse_args()
    if len(args) < 2:
        parser.error("At least 2 arguments are required")

    try:
        orig = Artifact.from_mvn_str(args[0])
        orig.validate(allow_backref=False)
        XMvnConfig().add_compat_versions(orig, args[1:])
    except (ArtifactValidationException, ArtifactFormatException) as e:
        parser.error("{e}: Provided artifact strings were invalid. "
                     "Please see help  and check your arguments".format(e=e))
        sys.exit(1)
    except JavaPackagesToolsException as e:
        sys.exit(e)
예제 #19
0
def _main():
    OptionParser.format_epilog = lambda self, formatter: self.epilog
    parser = OptionParser(usage=usage, epilog=epilog)
    parser.add_option("--skip-dependencies",
                      action="store_true",
                      default=False,
                      help="skip dependencies section in resulting metadata")
    parser.add_option("-D",
                      action="append",
                      type="str",
                      help="add artifact property",
                      metavar="property=value")

    sys.argv = args_to_unicode(sys.argv)

    (options, args) = parser.parse_args()
    if len(args) < 1:
        parser.error("At least 1 argument is required")

    try:
        uart = Artifact.from_mvn_str(args[0])
        uart.validate(allow_backref=False)
        if len(args) == 1:
            parser.error(
                "When using artifact specification artifact path must be "
                "provided")
        if not (uart.groupId and uart.artifactId and uart.version):
            parser.error("Defined artifact has to include at least groupId, "
                         "artifactId and version")
    except (ArtifactFormatException):
        if is_it_ivy_file(args[0]):
            uart = IvyFile(args[0])
        else:
            # it should be good old POM file
            uart = POM(args[0])
        pom_path = args[0]
    else:
        pom_path = None

    art = MetadataArtifact(uart.groupId, uart.artifactId, version=uart.version)
    if hasattr(uart, "extension") and uart.extension:
        art.extension = uart.extension
    if hasattr(uart, "classifier") and uart.classifier:
        art.classifier = uart.classifier

    jar_path = None
    if len(args) > 1:
        jar_path = args[1]
        extension = (os.path.splitext(jar_path)[1])[1:]
        if hasattr(
                art, "extension"
        ) and art.extension and art.extension != extension and not pom_path:
            raise ExtensionsDontMatch("Extensions don't match: '%s' != '%s'" %
                                      (art.extension, extension))
        else:
            art.extension = extension
    else:
        art.extension = "pom"

    if os.path.exists(config):
        metadata = Metadata.create_from_file(config)
    else:
        metadata = Metadata()

    if (not options.skip_dependencies and pom_path
            and not is_it_ivy_file(pom_path)):
        deps = []
        mvn_deps = gather_dependencies(pom_path)
        for d in mvn_deps:
            deps.append(MetadataDependency.from_mvn_dependency(d))
        if deps:
            art.dependencies = set(deps)
    else:
        art.properties["xmvn.resolver.disableEffectivePom"] = "true"

    if options.D:
        for d_opt in options.D:
            key, value = d_opt.split("=")
            art.properties[key] = value

    add_artifact_elements(metadata, art, pom_path, jar_path)

    metadata.write_to_file(config)
예제 #20
0
Wildcards (*) and empty parts in specifications are allowed (treated as wildcard).

Examples of valid specifications:
commons-lang:commons-lang:1.2
commons-lang:commons-lang:war:
commons-lang:commons-lang:war:test-jar:
commons-lang:commons-lang:war:test-jar:3.1
*:commons-lang (equivalent to ':commons-lang')
"""

if __name__ == "__main__":
    parser = SaneParser(usage=usage, epilog=epilog)

    sys.argv = args_to_unicode(sys.argv)

    (options, args) = parser.parse_args()
    if len(args) < 2:
        parser.error("At least 2 arguments are required")

    try:
        orig = Artifact.from_mvn_str(args[0])
        aliases = []
        for alias in args[1:]:
            aliases.append(Artifact.from_mvn_str(alias))

        XMvnConfig().add_aliases(orig, aliases)
    except (ArtifactValidationException, ArtifactFormatException) as e:
        parser.error("{e}: Provided artifact strings were invalid. "
                     "Please see help  and check your arguments".format(e=e))
        sys.exit(1)
예제 #21
0
commons-lang:commons-lang:1.2
commons-lang:commons-lang:war:
commons-lang:commons-lang:war:test-jar:
commons-lang:commons-lang:war:test-jar:3.1
*:commons-lang (equivalent to ':commons-lang')
"""

if __name__ == "__main__":
    parser = SaneParser(usage=usage,
                        epilog=epilog)
    sys.argv = args_to_unicode(sys.argv)

    (options, args) = parser.parse_args()

    if len(args) == 0:
        parser.error("At least one argument required")
    elif len(args) > 2:
        parser.error("At most 2 arguments are expected")
    elif len(args) == 1:
        args.append("__default")

    try:
        orig = Artifact.from_mvn_str(args[0])
        XMvnConfig().add_package_mapping(orig, args[1])
    except (ArtifactValidationException, ArtifactFormatException) as e:
        parser.error("{e}: Provided artifact strings were invalid. "
                     "Please see help  and check your arguments".format(e=e))
        sys.exit(1)
    except JavaPackagesToolsException as e:
        sys.exit(e)
예제 #22
0
def _main():
    OptionParser.format_epilog = lambda self, formatter: self.epilog
    parser = OptionParser(usage=usage, epilog=epilog)
    parser.add_option(
        "--skip-dependencies",
        action="store_true",
        default=False,
        help="skip dependencies section in resulting metadata",
    )
    parser.add_option("-D", action="append", type="str", help="add artifact property", metavar="property=value")

    sys.argv = args_to_unicode(sys.argv)

    (options, args) = parser.parse_args()
    if len(args) < 1:
        parser.error("At least 1 argument is required")

    try:
        uart = Artifact.from_mvn_str(args[0])
        uart.validate(allow_backref=False)
        if len(args) == 1:
            parser.error("When using artifact specification artifact path must be " "provided")
        if not (uart.groupId and uart.artifactId and uart.version):
            parser.error("Defined artifact has to include at least groupId, " "artifactId and version")
    except (ArtifactFormatException):
        if is_it_ivy_file(args[0]):
            uart = IvyFile(args[0])
        else:
            # it should be good old POM file
            uart = POM(args[0])
        pom_path = args[0]
    else:
        pom_path = None

    art = MetadataArtifact(uart.groupId, uart.artifactId, version=uart.version)
    if hasattr(uart, "extension") and uart.extension:
        art.extension = uart.extension
    if hasattr(uart, "classifier") and uart.classifier:
        art.classifier = uart.classifier

    jar_path = None
    if len(args) > 1:
        jar_path = args[1]
        extension = (os.path.splitext(jar_path)[1])[1:]
        if hasattr(art, "extension") and art.extension and art.extension != extension and not pom_path:
            raise ExtensionsDontMatch("Extensions don't match: '%s' != '%s'" % (art.extension, extension))
        else:
            art.extension = extension
    else:
        art.extension = "pom"

    if os.path.exists(config):
        metadata = Metadata.create_from_file(config)
    else:
        metadata = Metadata()

    if not options.skip_dependencies and pom_path and not is_it_ivy_file(pom_path):
        deps = []
        mvn_deps = gather_dependencies(pom_path)
        for d in mvn_deps:
            deps.append(MetadataDependency.from_mvn_dependency(d))
        if deps:
            art.dependencies = set(deps)
    else:
        art.properties["xmvn.resolver.disableEffectivePom"] = "true"

    if options.D:
        for d_opt in options.D:
            key, value = d_opt.split("=")
            art.properties[key] = value

    add_artifact_elements(metadata, art, pom_path, jar_path)

    metadata.write_to_file(config)
예제 #23
0
    def from_mvn_str(cls, mvn_str):
        a = Artifact.from_mvn_str(mvn_str)

        return cls(a.groupId, a.artifactId, extension=a.extension,
                   classifier=a.classifier, requestedVersion=a.version)
예제 #24
0
commons-lang:commons-lang:1.2
commons-lang:commons-lang:war:
commons-lang:commons-lang:war:test-jar:
commons-lang:commons-lang:war:test-jar:3.1
*:commons-lang (equivalent to ':commons-lang')
"""

if __name__ == "__main__":
    parser = SaneParser(usage=usage,
                        epilog=epilog)

    sys.argv = args_to_unicode(sys.argv)

    (options, args) = parser.parse_args()
    if len(args) < 2:
        parser.error("At least 2 arguments are required")

    try:
        orig = Artifact.from_mvn_str(args[0])
        aliases = []
        for alias in args[1:]:
            aliases.append(Artifact.from_mvn_str(alias))

        XMvnConfig().add_aliases(orig, aliases)
    except (ArtifactValidationException, ArtifactFormatException) as e:
        parser.error("{e}: Provided artifact strings were invalid. "
                     "Please see help  and check your arguments".format(e=e))
        sys.exit(1)
    except JavaPackagesToolsException as e:
        sys.exit(e)