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

3.2.9: dependencies missing in pom file #10619

Closed
mhuebner opened this issue May 2, 2017 · 6 comments
Closed

3.2.9: dependencies missing in pom file #10619

mhuebner opened this issue May 2, 2017 · 6 comments

Comments

@mhuebner
Copy link

mhuebner commented May 2, 2017

Steps to Reproduce

  1. Clone this multi project sample app: https://github.com/mhuebner/grails329-pom-issue
  2. sub1 is a non-grails app, sub2 is a grails app (gradle-grails-plugin applied)
  3. run gradlew clean publishToMavenLocal
  4. look into the resulting locally published pom file of the project's modules (sub1 and sub2)
  5. these missing dependencies are completely breaking our automated builds. So upgrading to Grails 3.2.9 is not possible. We use all these pom stuff in a ton of pipeline builds.

The sample app is a multi project app just so demonstrate the different behaviour of a grails and a non-grails project.

Expected Behaviour

Modules sub1 and sub2 should contain the correct dependencies in their locally published pom files.
I do not want to publish to grails central or bintray. Just to a plain old maven repo (local or remote).

Actual Behaviour

pom file of sub1 (non-grails submodule) contains every definied compile-dependency
pom file of sub1 (grails submodule) does NOT contain the compile dependencies

When applying the grails-gradle-plugin, this strange behaviour can be seen.

Some more details:

sub1 contains the following dependency-block:

dependencies {    
    compile "joda-time:joda-time:2.1"
}

and the resulting pom contains this dependency as expected:

  <dependencies>
    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>2.1</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>

sub2 contains these dependencies:

dependencies {
    compile "org.codehaus.groovy:groovy:2.4.10"
    compile "org.mindrot:jbcrypt:0.3m"
}

The resulting pom file of sub2 misses these dependencies. Just the dependencyManagement block is defined. Groovy and jbcrypt are missing.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.test</groupId>
  <artifactId>sub2</artifactId>
  <version>1.0-SNAPSHOT</version>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.6.RELEASE</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
      <dependency>
        <groupId>org.grails</groupId>
        <artifactId>grails-bom</artifactId>
        <version>3.2.9</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>

Environment Information

  • Operating System: Win64
  • Grails Version: 2.3.9
  • JDK Version: OpenJDK 1.8

Example Application

https://github.com/mhuebner/grails329-pom-issue

@jameskleeh
Copy link
Contributor

jameskleeh commented May 5, 2017

I can't assemble the project. If sub2 is a grails app, where are the grails dependencies (other than gradle) ?

Jamess-MacBook-Pro:grails329-pom-issue jameskleeh$ ./gradlew clean assemble
Starting a Gradle Daemon (subsequent builds will be faster)
Download https://repo1.maven.org/maven2/org/mindrot/jbcrypt/0.3m/jbcrypt-0.3m.pom
Download https://repo1.maven.org/maven2/org/mindrot/jbcrypt/0.3m/jbcrypt-0.3m.jar
:clean UP-TO-DATE
:sub1:clean UP-TO-DATE
:sub2:clean
:compileJava NO-SOURCE
:processResources NO-SOURCE
:classes UP-TO-DATE
:jar
:assemble
:sub1:compileJava NO-SOURCE
:sub1:processResources NO-SOURCE
:sub1:classes UP-TO-DATE
:sub1:jar
:sub1:assemble
:sub2:compileAstJava NO-SOURCE
:sub2:compileAstGroovy NO-SOURCE
:sub2:processAstResources NO-SOURCE
:sub2:astClasses UP-TO-DATE
:sub2:compileJava NO-SOURCE
:sub2:configScript
:sub2:compileGroovy
startup failed:
/Users/jameskleeh/IdeaProjects/sample-projects/grails329-pom-issue/sub2/grails-app/init/sub2/Application.groovy: 3: unable to resolve class grails.boot.GrailsApp
 @ line 3, column 1.
   import grails.boot.GrailsApp
   ^

/Users/jameskleeh/IdeaProjects/sample-projects/grails329-pom-issue/sub2/grails-app/init/sub2/Application.groovy: 4: unable to resolve class grails.boot.config.GrailsAutoConfiguration
 @ line 4, column 1.
   import grails.boot.config.GrailsAutoConfiguration
   ^

2 errors

:sub2:compileGroovy FAILED

@mhuebner
Copy link
Author

mhuebner commented May 8, 2017

@jameskleeh I was not able to reproduce your assembling issue. Even a clean repo clone assembles successfully. Nevertheless I added some core dependencies. Hopefully it will assemble now. Please do a git pull.

@graemerocher
Copy link
Member

FWIW I see the same behaviour as @jameskleeh and had to add the core dependencies

@jameskleeh
Copy link
Contributor

In the sub2 module, it does not contain those dependencies:

dependencies {
    compile "org.codehaus.groovy:groovy:2.4.10"
    compile "org.mindrot:jbcrypt:0.3m"
}

@graemerocher
Copy link
Member

This seems to be an issue with how you have structured your build. Attached a patch that demonstrates how to get it working.

10619.patch.txt

@mhuebner
Copy link
Author

mhuebner commented May 9, 2017

@graemerocher thank you for clarifiying. The bahaviour seems to have changed. In 3.2.3 it was ok to apply jave/grails plugins in the subprojects. Now you have to apply them after the maven-plugin is applied. The reason why the publications defined in the subprojects as well as in the root project is that we need to publish the complete build together with all submodules.

Here is the working example:

buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
    }
}

allprojects {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    version = "1.0-SNAPSHOT"
    group = "org.test"
}

subprojects { sub ->
    if (sub.name == 'sub2') {
        apply plugin: "org.grails.grails-plugin"
    } else {
        apply plugin: "java"
    }

    apply plugin: "maven-publish"

    configure(sub) {
        publishing {
            publications {
                mavenJava(MavenPublication) {
                    from components.java
                }
            }
        }
    }
}

apply plugin: "maven-publish"
publishing {
    publications {
        mavenJava(MavenPublication)
    }
}

Thank you for looking into this issue.

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

No branches or pull requests

3 participants