Skip to content

Commit

Permalink
Merge pull request #12 from ergon/bugfix/gradle_classloader
Browse files Browse the repository at this point in the history
Use local class loader to find the required classes also in gradle
  • Loading branch information
rbuehlma authored Oct 3, 2024
2 parents a44c74f + 5923c83 commit 2cd816b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ out/
build/
/integration-test-db/src/main/resources/adamd/target_version
gradle-plugin-test/.gradle/
gradle-plugin-test/gradle/
gradle-plugin-test/gradlew*
gradle.properties
local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ReflectionHelper {
private static Set<Class<?>> findAllClassesForPackage(String packageName) {
if (!classesByPackageCache.containsKey(packageName)) {
try {
Set<Class<?>> classes = ClassPath.from(ClassLoader.getSystemClassLoader()).getAllClasses()
Set<Class<?>> classes = ClassPath.from(ReflectionHelper.class.getClassLoader()).getAllClasses()
.stream()
.filter(c -> c.getPackageName().startsWith(packageName))
.map(ClassPath.ClassInfo::getName)
Expand Down
6 changes: 3 additions & 3 deletions gradle-plugin-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ buildscript {
}

dependencies {
classpath 'ch.ergon.adam:postgresql:1.0.0'
classpath 'ch.ergon.adam:yml:1.0.0'
classpath 'ch.ergon.adam:postgresql:1.2.2'
classpath 'ch.ergon.adam:yml:1.2.2'
}
}

plugins {
id 'java'
id 'ch.ergon.adam' version '1.0.0'
id 'ch.ergon.adam' version '1.2.2'
}

adam {
Expand Down
10 changes: 10 additions & 0 deletions gradle-plugin-test/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven {
name = "localPluginRepository"
url = uri("/tmp/adam/local-gradle-plugin-repository")
}
}
}

rootProject.name = 'adam-gradleplugin-test'

0 comments on commit 2cd816b

Please sign in to comment.