diffplug / goomph

IDE as build artifact
Apache License 2.0
130 stars 30 forks source link

Update p2AsMaven docs for multi-project usage in Gradle 6+ #119

Closed drkstr101 closed 4 years ago

drkstr101 commented 4 years ago

Hello,

I just wanted to inform you that the p2AsMaven task does not appear to work in Gradle versions greater than 5.6.4.

Here is an example build that works in 5.6.4 but not 6.0.

enm.model/build.gradle

plugins {
    // Apply the java-library plugin to add support for Java Library
    id 'java-library'
}

// we need the maven repo from p2
evaluationDependsOn(':enm.model.p2')

repositories {
    jcenter()
    mavenCentral()
    maven {
        url project(':enm.model.p2').file('build/p2asmaven/maven')
    }
}

dependencies {

    api 'eclipse-deps:org.eclipse.emf.ecore:+',
            'eclipse-deps:org.eclipse.emf.common:+',
            'eclipse-deps:org.eclipse.emf.ecore.xmi:+',
            'eclipse-deps:org.eclipse.core.runtime:+'
}

enm.model.p2/build.gradle

apply plugin: 'com.diffplug.gradle.p2.asmaven'

p2AsMaven {
    group 'eclipse-deps', {
        repo 'http://download.eclipse.org/releases/2019-12'
        feature 'org.eclipse.platform'
        feature 'org.eclipse.platform.source'
        feature 'org.eclipse.emf.ecore'
        iu 'org.eclipse.emf.ecp.edit'
        iu 'org.eclipse.core.runtime'
        iu 'org.eclipse.emf.edit.ui'
        iu 'org.eclipse.emf.common.ui'
        append true //not required for solution
        repo2runnable()
    }
}

Running the build in 6.0 results in:

Execution failed for task ':enm.model:compileJava'.
> Could not resolve all files for configuration ':enm.model:compileClasspath'.
> Could not find any matches for eclipse-deps:org.eclipse.emf.ecore:+ as no versions of eclipse-deps:org.eclipse.emf.ecore are available.
    Searched in the following locations:
    - https://jcenter.bintray.com/eclipse-deps/org.eclipse.emf.ecore/maven-metadata.xml
    - https://repo.maven.apache.org/maven2/eclipse-deps/org.eclipse.emf.ecore/maven-metadata.xml
    - file:/home/amiller/Workspace/enm/enm-model/enm.model.p2/build/p2asmaven/maven/eclipse-deps/org.eclipse.emf.ecore/maven-metadata.xml
    - file:/home/amiller/Workspace/enm/enm-model/enm.model.p2/build/p2asmaven/maven/eclipse-deps/org.eclipse.emf.ecore/2.20.0.v20190920-0401/org.eclipse.emf.ecore-2.20.0.v20190920-0401.pom
    Required by:
        project :enm.model

repeated for each dependency

Note: The repository exists and is valid in both cases. Perhaps gradle 6 has stricter constraints on version matching the dependency?

nedtwigg commented 4 years ago

What version are you using? Goomph 3.20.0 fixed compat with Gradle 6.

drkstr101 commented 4 years ago

Odd, I am on 3.21.0. I'm investigating further to see if I can narrow down the issue.

drkstr101 commented 4 years ago

My mistake.

The com.diffplug.gradle.p2.asmaven plugin has been deprecated.   
This is scheduled to be removed in Gradle 6.0.   
Please use the com.diffplug.p2.asmaven plugin instead.
drkstr101 commented 4 years ago

It still failed after making the change and doing a clean build of the maven repo.

Build scan here: https://gradle.com/s/7qczvv44rxefy

nedtwigg commented 4 years ago

Aha. It's because you're creating the repo yourself. Goomph does this automatically, but since you're using p2asmaven in its own project (which is perfectly valid), you need to make this change:

maven {
  url project(':enm.model.p2').file('build/p2asmaven/maven')
  metadataSources {
    mavenPom()
    artifact()
  }
}

I think it's common to use p2asmaven this way, so we should probably update the docs to point people to this. Lemme know if this fixes it for you.

drkstr101 commented 4 years ago

That most certainly did the trick! It now works as expected. Cheers, and thank you for your time!

nedtwigg commented 4 years ago

Fixed in 3.23.0

drkstr101 commented 4 years ago

Awesome, keep up the great work! IMHO this plugin is a lot more ergonomic than Tycho/Maven builds. I am delighted to have stumbled upon it.