peter
peter

Reputation: 3

gradle: import github project as dependency

I need the latest version of the github project (v3.0.0)

https://github.com/appreciated/grid-layout

It's not yet available on mvnrepository ... I tried it with

repositories {
    maven { url "https://jitpack.io" }
}
dependencies {
    implementation 'com.github.appreciated:grid-layout:-SNAPSHOT'
}

(I also tried different versions 'master-SNAPSHOT', '6302f04026', ...)

https://jitpack.io/com/github/appreciated/grid-layout/6302f04026/build.log shows an error while building...

I also tried to set sourceControl in the settings.gradle file and the import with different versions... settings.gradle

sourceControl {
    gitRepository(URI.create("https://github.com/appreciated/grid-layout.git")) {
        producesModule("com.github.appreciated:grid-layout")
    }
}

build.gradle

dependencies {
    implementation 'com.github.appreciated:grid-layout:3.0.0'
}

Is there any other way to get this project as dependency?!

edit: gradle 8.5 and java21

=============================================================

Edit for a cringe workaround: probably not the best solution...

root project settings.gradle

includeBuild("ext/grid-layout") {
    dependencySubstitution {
        substitute module('com.github.appreciated:vaadin-css-grid') using project(':')
    }
}

grid-layout build.gradle

plugins {
    id 'java'
    id 'org.ajoberstar.grgit' version '5.2.1'
}

// import properties of root project gradle.properties
try {
    Properties props = new Properties()
    props.load(new FileInputStream("$rootDir/../../gradle.properties"))
    props.each { prop -> project.ext.setProperty(prop.key, prop.value) }
} catch (exception) {
    throw new InvalidUserDataException("Parameters not found : $exception.message")
}
repositories {
    mavenCentral()
    maven {
        url "https://vaadin.com/nexus/content/repositories/vaadin-addons/"
    }
}
// dependencies of pom.xml
dependencies {
    implementation "com.vaadin:vaadin:$vaadinVersion"
    implementation "com.vaadin:vaadin-core:$vaadinVersion"
    implementation "org.vaddon:mediaquery:5.0.3"
}

group "com.github.appreciated"
version "3.0.0"

def downloadDir = "$projectDir/build/tmp/"
def generatedClasses = file("$downloadDir/src/main/java")
def generatedResources = file("$downloadDir/src/main/resources")

tasks.register("downloadProject") {
    outputs.dirs downloadDir
    def folder = file(downloadDir)
    doFirst {
        assert folder.exists() || folder.mkdirs()
        grgit.clone(dir: folder, uri: 'https://github.com/appreciated/grid-layout.git')
    }
    onlyIf {
        !folder.exists()
    }
}

sourceSets.main.java.srcDirs += generatedClasses.absolutePath
sourceSets.main.resources.srcDirs += generatedResources.absolutePath
compileJava.dependsOn downloadProject

Upvotes: 0

Views: 165

Answers (0)

Related Questions