Example #1
0
def __cleanup_classpath(bundle):
    """
    Cleanup the classpath of the specified Eclipse bundle
    :param bundle: An Eclipse bundle
    :return: None
    """
    subs = os.listdir(bundle.location)
    if not ".classpath" in subs:
        return
    doc = xml.dom.minidom.parse(os.path.join(bundle.location, ".classpath"))
    dirty = False
    for entry in doc.getElementsByTagName("classpathentry"):
        data = entry.getAttribute("excluding")
        folder = entry.getAttribute("path")
        if data is not None and len(data) > 0:
            files = data.split("|")
            for file in files:
                if file is not None and len(file) > 0:
                    dirty = True
                    full = os.path.join(bundle.location, os.path.join(folder, os.path.join(file)))
                    print("Found " + full)
                    if full.endswith("/"):
                        subprocess.call(["git", "rm", "-r", full])
                    else:
                        subprocess.call(["git", "rm", full])
            entry.parentNode.removeChild(entry)
    if dirty:
        xmlutils.output(doc, os.path.join(bundle.location, ".classpath"))
        console.log("Bundle " + bundle.name + " => Fixed .classpath to remove excluded sources")
Example #2
0
def update(simrel, target):
    """
    Update the given Tycho pom.xml file with new update sites
    :param simrel: Path to the local simrel repository
    :param target: Path to the target pom.xml to update
    :return: None
    """
    console.log("Reading " + target)
    pom = xml.dom.minidom.parse(target)

    console.log("Updating " + target)
    for node in pom.getElementsByTagName("repository"):
        identifier = node.getElementsByTagName("id")[0].childNodes[0].data
        url = node.getElementsByTagName("url")[0].childNodes[0].data
        data = __get_url_for(simrel, identifier)
        if data is None:
            console.log(identifier + " => no matching repository found",
                        "WARNING")
        else:
            if data == url:
                console.log(identifier + " => no change")
            else:
                node.getElementsByTagName("url")[0].childNodes[0].data = data
                console.log(identifier + " => updated to " + data)

    console.log("Writing back " + target)
    xmlutils.output(pom, target)
Example #3
0
def update(simrel, target):
    """
    Update the given Tycho pom.xml file with new update sites
    :param simrel: Path to the local simrel repository
    :param target: Path to the target pom.xml to update
    :return: None
    """
    console.log("Reading " + target)
    pom = xml.dom.minidom.parse(target)

    console.log("Updating " + target)
    for node in pom.getElementsByTagName("repository"):
        identifier = node.getElementsByTagName("id")[0].childNodes[0].data
        url = node.getElementsByTagName("url")[0].childNodes[0].data
        data = __get_url_for(simrel, identifier)
        if data is None:
            console.log(identifier + " => no matching repository found", "WARNING")
        else:
            if data == url:
                console.log(identifier + " => no change")
            else:
                node.getElementsByTagName("url")[0].childNodes[0].data = data
                console.log(identifier + " => updated to " + data)

    console.log("Writing back " + target)
    xmlutils.output(pom, target)
Example #4
0
def __cleanup_classpath(bundle):
    """
    Cleanup the classpath of the specified Eclipse bundle
    :param bundle: An Eclipse bundle
    :return: None
    """
    subs = os.listdir(bundle.location)
    if not ".classpath" in subs:
        return
    doc = xml.dom.minidom.parse(os.path.join(bundle.location, ".classpath"))
    dirty = False
    for entry in doc.getElementsByTagName("classpathentry"):
        data = entry.getAttribute("excluding")
        folder = entry.getAttribute("path")
        if data is not None and len(data) > 0:
            files = data.split("|")
            for file in files:
                if file is not None and len(file) > 0:
                    dirty = True
                    full = os.path.join(
                        bundle.location,
                        os.path.join(folder, os.path.join(file)))
                    print("Found " + full)
                    if full.endswith("/"):
                        subprocess.call(["git", "rm", "-r", full])
                    else:
                        subprocess.call(["git", "rm", full])
            entry.parentNode.removeChild(entry)
    if dirty:
        xmlutils.output(doc, os.path.join(bundle.location, ".classpath"))
        console.log("Bundle " + bundle.name +
                    " => Fixed .classpath to remove excluded sources")
Example #5
0
def __generate_bundle_pom(bundle, packaging):
    """
    Generate the pom.xml file for the given bundle and given packaging
    :param bundle: The bundle to generate the pom for
    :param packaging: The type of packaging (feature or plugin)
    :return: True if the operation succeeded, False otherwise
    """
    if len(bundle.targets) == 0:
        console.log("Bundle " + bundle.name + " has no target => skipped", "WARNING")
        return True
    if len(bundle.targets) >= 2:
        console.log("Bundle " + bundle.name + " has more than one target:", "ERROR")
        for target in bundle.targets:
            console.log("\t" + target, "ERROR")
        return False
    if os.path.isfile(os.path.join(bundle.location, "pom.xml")):
        console.log("Bundle " + bundle.name + " already has pom.xml => skipped")
        return True
    relative = os.path.relpath(".", bundle.location)
    relative = os.path.join(relative, bundle.targets[0].pom)
    impl = xml.dom.minidom.getDOMImplementation()
    doc = impl.createDocument(None, "project", None)
    project = doc.documentElement
    __xml_append_text(doc, project, "modelVersion", MAVEN_MODEL_VERSION)
    parent = doc.createElement("parent")
    project.appendChild(parent)
    __xml_append_tycho_ref(doc, parent, PRODUCT_GROUP)
    __xml_append_text(doc, parent, "relativePath", relative)
    __xml_append_tycho_ref(doc, project, bundle.name)
    __xml_append_text(doc, project, "packaging", packaging)
    xmlutils.output(doc, os.path.join(bundle.location, "pom.xml"))
    console.log("Bundle " + bundle.name + " POM generated for target " + bundle.targets[0].name)
    return True
Example #6
0
def update(simrel, target):
	console.log("Reading " + target)
	pom = xml.dom.minidom.parse(target)
	
	console.log("Updating " + target)
	for node in pom.getElementsByTagName("repository"):
		id = node.getElementsByTagName("id")[0].childNodes[0].data
		url = node.getElementsByTagName("url")[0].childNodes[0].data
		data = getURLFor(simrel, id)
		if data == None:
			console.log(id + " => no matching repository found", "WARNING")
		else:
			if data == url:
				console.log(id + " => no change")
			else:
				node.getElementsByTagName("url")[0].childNodes[0].data = data
				console.log(id + " => updated to " + data)
	
	console.log("Writing back " + target)
	xmlutils.output(pom, target)
Example #7
0
def __generate_bundle_pom(bundle, packaging):
    """
    Generate the pom.xml file for the given bundle and given packaging
    :param bundle: The bundle to generate the pom for
    :param packaging: The type of packaging (feature or plugin)
    :return: True if the operation succeeded, False otherwise
    """
    if len(bundle.targets) == 0:
        console.log("Bundle " + bundle.name + " has no target => skipped",
                    "WARNING")
        return True
    if len(bundle.targets) >= 2:
        console.log("Bundle " + bundle.name + " has more than one target:",
                    "ERROR")
        for target in bundle.targets:
            console.log("\t" + target, "ERROR")
        return False
    if os.path.isfile(os.path.join(bundle.location, "pom.xml")):
        console.log("Bundle " + bundle.name +
                    " already has pom.xml => skipped")
        return True
    relative = os.path.relpath(".", bundle.location)
    relative = os.path.join(relative, bundle.targets[0].pom)
    impl = xml.dom.minidom.getDOMImplementation()
    doc = impl.createDocument(None, "project", None)
    project = doc.documentElement
    __xml_append_text(doc, project, "modelVersion", MAVEN_MODEL_VERSION)
    parent = doc.createElement("parent")
    project.appendChild(parent)
    __xml_append_tycho_ref(doc, parent, PRODUCT_GROUP)
    __xml_append_text(doc, parent, "relativePath", relative)
    __xml_append_tycho_ref(doc, project, bundle.name)
    __xml_append_text(doc, project, "packaging", packaging)
    xmlutils.output(doc, os.path.join(bundle.location, "pom.xml"))
    console.log("Bundle " + bundle.name + " POM generated for target " +
                bundle.targets[0].name)
    return True
Example #8
0
def __update_modules(repository, target):
    """
    Updates the modules for the given target
    :param repository: The Eclipse repository to work on
    :param target: The build target to update
    :return: None
    """
    doc = xml.dom.minidom.parse(target.pom)
    modules = doc.getElementsByTagName("modules")[0]
    for module in modules.getElementsByTagName("module"):
        modules.removeChild(module)
    for name in iter(sorted(repository.features)):
        feature = repository.features[name]
        if target in feature.targets:
            modules.appendChild(__get_module_node(feature, doc))
    for name in iter(sorted(repository.plugins)):
        plugin = repository.plugins[name]
        if target in plugin.targets:
            modules.appendChild(__get_module_node(plugin, doc))
    repo_node = doc.createElement("module")
    repo_node.appendChild(doc.createTextNode(target.name))
    modules.appendChild(repo_node)
    xmlutils.output(doc, target.pom)
    console.log("Updated top POM for target " + target.name)
Example #9
0
def __update_modules(repository, target):
    """
    Updates the modules for the given target
    :param repository: The Eclipse repository to work on
    :param target: The build target to update
    :return: None
    """
    doc = xml.dom.minidom.parse(target.pom)
    modules = doc.getElementsByTagName("modules")[0]
    for module in modules.getElementsByTagName("module"):
        modules.removeChild(module)
    for name in iter(sorted(repository.features)):
        feature = repository.features[name]
        if target in feature.targets:
            modules.appendChild(__get_module_node(feature, doc))
    for name in iter(sorted(repository.plugins)):
        plugin = repository.plugins[name]
        if target in plugin.targets:
            modules.appendChild(__get_module_node(plugin, doc))
    repo_node = doc.createElement("module")
    repo_node.appendChild(doc.createTextNode(target.name))
    modules.appendChild(repo_node)
    xmlutils.output(doc, target.pom)
    console.log("Updated top POM for target " + target.name)