allprojects { project ->
	task kotlinLSPDeps {
		task -> doLast {
			System.out.println ""
			System.out.println "gradle-version $gradleVersion"
			System.out.println "kotlin-lsp-project ${project.name}"

			if (project.hasProperty('android')) {
				project.android.getBootClasspath().each {
					System.out.println "kotlin-lsp-gradle $it"
				}
				if (project.android.hasProperty('applicationVariants')) {
					project.android.applicationVariants.all { variant ->

						def variantBase = variant.baseName.replaceAll("-", File.separator)

						def buildClasses = project.getBuildDir().absolutePath +
							File.separator + "intermediates" +
							File.separator + "classes" +
							File.separator + variantBase

						System.out.println "kotlin-lsp-gradle $buildClasses"

						def userClasses = project.getBuildDir().absolutePath +
							File.separator + "intermediates" +
							File.separator + "javac" +
							File.separator + variant.baseName.replaceAll("-", File.separator) +
							File.separator + "compile" + variantBase.capitalize() + "JavaWithJavac" + File.separator + "classes"

						System.out.println "kotlin-lsp-gradle $userClasses"

						variant.getCompileClasspath().each {
							System.out.println "kotlin-lsp-gradle $it"
						}
					}
				}
			} else {
				// Print the list of all dependencies jar files.
				project.configurations.findAll {
					it.metaClass.respondsTo(it, "isCanBeResolved") ? it.isCanBeResolved() : false
				}.each {
					it.resolve().each {
						def inspected = it.inspect()
						
						if (inspected.endsWith("jar")) {
							if (!inspected.contains("zip!")) {
								System.out.println "kotlin-lsp-gradle $it"
							}
						} else if (inspected.endsWith("aar")) {
							// If the dependency is an AAR file we try to determine the location
							// of the classes.jar file in the exploded aar folder.
							def splitted = inspected.split("/")
							def namespace = splitted[-5]
							def name = splitted[-4]
							def version = splitted[-3]
							def explodedPath = "$project.buildDir/intermediates/exploded-aar/$namespace/$name/$version/jars/classes.jar"
							System.out.println "kotlin-lsp-gradle $explodedPath"
						}
					}
				}
			}
		}
	}
}
