Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Update Sites as Bundle Source #102

Open
jGleitz opened this issue Jan 15, 2016 · 3 comments
Open

Use Update Sites as Bundle Source #102

jGleitz opened this issue Jan 15, 2016 · 3 comments

Comments

@jGleitz
Copy link

jGleitz commented Jan 15, 2016

I am very sorry if I’m missing a major point here. But I’ve read all of this project’s wiki pages and tried a lot of things, but still can figure it out:

In our MANIFEST.MF, we require the Apache Commons:

Require-Bundle: org.apache.commons.lang3;bundle-version="3.1.0"

If we try to build that using wuff, we get:

* What went wrong:
Could not resolve all dependencies for configuration ':Prototypes/Eclipse Build:compile'.
> Could not find eclipse-luna-sr2:org.apache.commons.lang3:3.1.0.
  Searched in the following locations:
      https://repo1.maven.org/maven2/eclipse-luna-sr2/org.apache.commons.lang3/3.1.0/org.apache.commons.lang3-3.1.0.pom
      https://repo1.maven.org/maven2/eclipse-luna-sr2/org.apache.commons.lang3/3.1.0/org.apache.commons.lang3-3.1.0.jar
      file:/home/josh/.wuff/m2_repository/eclipse-luna-sr2/org.apache.commons.lang3/3.1.0/org.apache.commons.lang3-3.1.0.pom
      file:/home/josh/.wuff/m2_repository/eclipse-luna-sr2/org.apache.commons.lang3/3.1.0/org.apache.commons.lang3-3.1.0.jar
  Required by:
      Beagle:Prototypes/Eclipse Build:0.0.1

Now on one hand it’s totally clear what’s happening here: lang3 is not part of a default Eclipse installation. But: How do we solve this?
We do not want to include the jar of the Apache Commons in our project, because we believe this is not how it’s supposed to work. We want to declare the dependency in MANIFEST.ML.

I expected to be able to point wuff to a target platform definition so it can retrieve further plugins from there, but I found no such option?

How do we point wuff where to get this plugin from?

This might be related to #75 and #98

@jGleitz jGleitz changed the title How to use external libraries? Use Update Sites as Bundle Source Jan 16, 2016
@jGleitz
Copy link
Author

jGleitz commented Jan 16, 2016

For anybody interested, I managed to add update sites to look for dependencies like this: (heavily inspired by #9):

buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }

    dependencies {
        classpath group: 'org.akhikhl.wuff', name: 'wuff-plugin', version: '+'
        classpath group: 'de.undercouch', name: 'gradle-download-task', version: '+'
        classpath group: 'org.apache.ivy', name: 'ivy', version: '+' 
    }
}

import org.akhikhl.wuff.EclipseBundlePlugin
import de.undercouch.gradle.tasks.download.DownloadTaskPlugin
import org.apache.ivy.util.url.ApacheURLLister

apply plugin: EclipseBundlePlugin
apply plugin: DownloadTaskPlugin

def lister = new ApacheURLLister()
def downloadUpdatesite

/**
 * Recursivly downloads an update site.
 */
downloadUpdatesite = { URL url, destinationDir ->
    file(destinationDir).mkdirs()
    project.download {
        src lister.listFiles(url)
        dest destinationDir
    }
    for (folder in lister.listDirectories(url)) {
        def destPart = url.toURI().relativize(folder.toURI()).toString()
        downloadUpdatesite folder, "$destinationDir/$destPart" 
    }
}

/**
 * Downloads an update site and provides a path to it to be used by wuff.
 * 
 * @param url The update site’s url.
 */
def updatesite = { url ->
    // create a folder name out of the URL
    def dirName = url.replaceAll("[^a-zA-Z0-9.-]", "_")
    def wuffDir = project.wuff.wuffDir ?: System.getProperty('user.home') + '/.wuff'

    // imitate unpuzzle’s checksum mechanism
    def checksumFile = file("$wuffDir/downloaded-checksums/${dirName}.md5")
    checksumFile.parentFile.mkdirs()
    def destinationDir = "$wuffDir/unpacked/$dirName"

    if (!checksumFile.exists() || !file(destinationDir).isDirectory()) {
        downloadUpdatesite new URL(url), destinationDir
        // unpuzzle’s dummy checksum
        checksumFile.text = 'deadbea1'
    }
    return "file://$destinationDir"
}

project.wuff {
    selectedEclipseVersion = '4.5'

    eclipseVersion('4.5') {
        sources {
            /*
             * Configure all update sites to get dependency plugins from here.
             */
            source updatesite("https://sdqweb.ipd.kit.edu/eclipse/palladiosimulator/nightly/aggregate/")
        }
    }
}

It simply downloads the whole update site and makes it available to wuff.

Obviously, this is far from perfect. If adding update sites for bundle sources would be supported (or somebody told me how to do this) I’d be very happy.

@izreal
Copy link

izreal commented Feb 11, 2016

@jGleitz your solution works pretty well when your P2 update site exposes index information for lister to consume. However, many update sites do not return index information and we fail with a "Please provide a download source" message.

For instance http://download.eclipse.org/eclipse/updates/4.5 fails with your code.

@jGleitz
Copy link
Author

jGleitz commented Feb 13, 2016

@izreal: I know that. But there is even a hack for the hack!

I know that this is super dirty – but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants