Compiled sub-project isn't added as dependency to root project
haze opened this issue · 8 comments
Given this file structure:
A
| B
| build.gradle (and etc)
If I link B (an eta project) to A (a java project)
B isn't automatically added as a dependency when eta is finished compiling, so A fails to compile as well when referencing exported code from B.
As reference this is the tree of the project folder: https://gist.github.com/hvze/41675ec80bf72e78f3bef296afe1c666
Those snippets are the gradle configuration (from @hvze in gitter):
anyways here is the dependency's build.gradle
plugins {
id 'com.typelead.eta'
}
group 'fi.ill.mod'
version '0.0.1-ec40f44'
allprojects {
repositories {
mavenCentral()
}
}
sourceSets {
main {
eta {
srcDir 'eta'
}
}
}
eta {
version = '0.7.2b1'
etlasVersion = '1.3.0.0'
}
dependencies {
compile eta('base:4.8.2.0')
}
apply plugin: 'idea'
root settings.gradle
include ':eta'
findProject(':eta')?.name = 'Lambda-Haskell'
root build.gradle
buildscript {
repositories {
jcenter()
maven { url = 'https://repo.spongepowered.org/maven' }
maven { url = "http://files.minecraftforge.net/maven" }
maven { url = 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath "gradle.plugin.com.typelead:gradle-eta:0.6.1"
classpath 'gradle.plugin.de.fuerstenau:BuildConfigPlugin:1.1.8'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'net.nemerosa:versioning:2.0.0'
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.3'
}
apply plugin: 'eta-base'
apply plugin: 'eta'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'net.nemerosa.versioning'
// apply plugin: 'de.fuerstenau.buildconfig'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'idea'
apply plugin: 'maven'
apply from: "gradle/scripts/deps.gradle"
apply from: "gradle/scripts/tasks.gradle"
version = "0.0.1-" + versioning.info.build
group = "fi.ill.mod"
archivesBaseName = "lambda"
/* mixin {
add sourceSets.main, "mixins.lambda.refmap.json"
} */
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
minecraft {
version = "1.12.2-14.23.3.2685"
runDir = "run"
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20171003"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
jar {
manifest {
attributes 'FMLCorePlugin': 'fi.ill.mod.ClientMod'
attributes 'FMLCorePluginContainsMod': 'true'
}
}
deps.gradle
repositories {
maven {
name = 'spongepowered-repo'
url = 'http://repo.spongepowered.org/maven/'
}
}
dependencies {
compile("org.spongepowered:mixin:0.7.4-SNAPSHOT") {
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
}
compile project(':Lambda-Haskell')
}
@hvze Can you try shifting:
eta {
version = '0.7.2b1'
etlasVersion = '1.3.0.0'
}
from your dependency's build.gradle to your root project's build.gradle? The plugin should actually not allow you to configure the eta
extension in subprojects but I guess that Gradle automatically inherits extensions from the root project.
@hvze I tried reproducing your issue with a minimal project here:
https://github.com/rahulmutt/java-eta-gradle
And I was unable to reproduce. If you can modify that project to reproduce your problem, it'll help track this down. I have a feeling this has to do with the way you exported - maybe a typo somewhere?
With that test project the issue still occurs, @rahulmutt
To reproduce, clone the repo locally and double-click (or open) the build.gradle with IntelliJ.
An alternative option would be to clone using the IDE itself, but it doesn't matter.
When building the projects, both work fine, but in the root java project, IntelliJ has problems displaying the exported java code. This is because the compiled eta code is not shown as a dependency
It seems if I update the build.gradle
as follows (manually supplying the eta RTS jars) and create a main
entrypoint in the Hello
class, we can get this to work. So ideally, gradle-eta
needs to add these RTS jars to the classpath for dependent projects.
Next, IntelliJ still doesn't resolve this correctly, even if I manually give the build.gradle
the following -
dependencies {
...
// Adding either of these doesn't seem to give IntelliJ a strong enough hint.
compile files("$userHome/dump/java-eta-gradle/eta/build/libs/HelloEta.jar")
runtime files("$userHome/dump/java-eta-gradle/eta/build/libs/HelloEta.jar")
}
In order to get IntelliJ to resolve the EtaExport
class, I had to manually add it by going to Project Structure, then adding the ./eta/build/libs/HelloEta.jar
to the java-eta-gradle_main
module.
build.gradle
plugins {
id 'com.typelead.eta.base' version '0.6.1'
id 'java'
}
apply plugin: 'application'
mainClassName = 'eta.test.Hello'
def userHome = System.getProperty('user.home')
dependencies {
compile project(':HelloEta')
runtime files(
"$userHome/.etlas/lib/eta-0.7.2.1/base-4.8.2.0-IPFDtZjmEfh5tPXF10v5hF/base-4.8.2.0-IPFDtZjmEfh5tPXF10v5hF.jar",
"$userHome/.etlas/lib/eta-0.7.2.1/ghc-prim-0.4.0.0-Jhi6UgHuZdoBZWUpVo3WKE/ghc-prim-0.4.0.0-Jhi6UgHuZdoBZWUpVo3WKE.jar",
"$userHome/.etlas/lib/eta-0.7.2.1/integer-0.5.1.0-ACyqTmAMUMGGvisLFeQbAm/integer-0.5.1.0-ACyqTmAMUMGGvisLFeQbAm.jar",
"$userHome/.etlas/lib/eta-0.7.2.1/rts-0.1.0.0-5Dj4qf1Wx9cCeYbpni5T1w/rts-0.1.0.0-5Dj4qf1Wx9cCeYbpni5T1w.jar"
)
}
Hello.java
package eta.test;
import eta.utils.EtaExport;
public class Hello {
public static void main(String[] args) {
System.out.println(new Hello().hello());
}
@carymrobbins Does setting preInstalledDependencies = true
in the eta
extension block change the behavior?
Most of the plugin code just deals with adding dependencies properly and the main issue you may hit is if something needs the dependencies before the Gradle task graph is constructed & executed. In this case, preInstalledDependencies = true
should inject all the dependencies across all source sets and all projects to the correct configurations. One way to ensure this is happening is by running with -i
and watching out for Resolving Eta configuration ...
messages.
Should be fixed in 0.6.6
.
@hvze @carymrobbins Any luck with 0.7.3
?