Jump to content

[1.7.10] [SOLVED] Linked source does not work with gradlew build?


Recommended Posts

Posted

Hello, today i met some problems with building my mod:

My mod depends on core mod, which is developped in different workspace. For ease of changing core mods' code, i link core mods' src/main/java to project using linkied sources.

When i try to build my mod, i get this in console:

C:\my\mcmodding\mods\Colourful-Blocks>gradlew build
****************************
Powered By MCP:
http://modcoderpack.com/
Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
MCP Data version : unknown
****************************
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava UP-TO-DATE
:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:37: error: cannot fin
d symbol
import code.elix_x.excore.utils.items.ItemStackStringTranslator;
                                     ^
  symbol:   class ItemStackStringTranslator
  location: package code.elix_x.excore.utils.items
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:39: error: package co
de.elix_x.excore.utils.recipes does not exist
import code.elix_x.excore.utils.recipes.RecipeStringTranslator;
                                       ^
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\tool\ColoringToolsManager.java:17: error: package code.elix_
x.excore.utils.recipes does not exist
import code.elix_x.excore.utils.recipes.RecipeStringTranslator;
                                       ^
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\ColourfulBlocksBase.java:37: error: cannot find symbol
@Mod(modid = ColourfulBlocksBase.MODID, name = ColourfulBlocksBase.NAME, version
= ColourfulBlocksBase.VERSION, dependencies = "required-after:" + EXCore.DEPEND
ENCY)

                                                                         ^
  symbol:   variable DEPENDENCY
  location: class EXCore
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\ColourfulBlocksManager.java:65: error: cannot find symbol
                                return rgba.argb();
                                           ^
  symbol:   method argb()
  location: variable rgba of type RGBA
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:101: error: cannot fi
nd symbol
                                        brushesNew.materials.add(new GsonMateria
lConversion(oldBrush.name, oldBrush.durability, oldBrush.buffer, oldBrush.color,
RECIPENAMEVANILLA, new GsonConversionRecipeEntry(RECIPEENTRYMATERIAL, oldBrush.
ingredient.replace("oredictionary:", ItemStackStringTranslator.OREDICT + ":"))))
;



                                     ^
  symbol:   variable ItemStackStringTranslator
  location: class ColoringMaterialsManager
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:238: error: method av
erage in class AdvancedMathUtils cannot be applied to given types;
                                        int r = AdvancedMathUtils.average(red[0]
, ArrayUtils.subarray(red, 1, red.length));
                                                                 ^
  required: double,double[]
  found: int,int[]
  reason: varargs mismatch; int[] cannot be converted to double
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:239: error: method av
erage in class AdvancedMathUtils cannot be applied to given types;
                                        int g = AdvancedMathUtils.average(green[
0], ArrayUtils.subarray(green, 1, green.length));
                                                                 ^
  required: double,double[]
  found: int,int[]
  reason: varargs mismatch; int[] cannot be converted to double
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:240: error: method av
erage in class AdvancedMathUtils cannot be applied to given types;
                                        int b = AdvancedMathUtils.average(blue[0
], ArrayUtils.subarray(blue, 1, blue.length));
                                                                 ^
  required: double,double[]
  found: int,int[]
  reason: varargs mismatch; int[] cannot be converted to double
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:241: error: no suitab
le constructor found for RGBA(int,int,int)
                                        color = new RGBA(r, g, b);
                                                ^
    constructor RGBA.RGBA() is not applicable
      (actual and formal argument lists differ in length)
    constructor RGBA.RGBA(int,int,int,int) is not applicable
      (actual and formal argument lists differ in length)
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:292: error: cannot fi
nd symbol
                                conversion.materials.add(new GsonMaterialConvers
ion(mat.name(), mat.getMaxUses(), mat.getHarvestLevel(), FMLCommonHandler.instan
ce().getSide() == Side.CLIENT ? recognizeColorToString(mat) : "0:0:0", RECIPENAM
EVANILLA, new GsonConversionRecipeEntry(RECIPEENTRYMATERIAL, ItemStackStringTran
slator.toString(recognizeRepairItem(mat)))));



                                                             ^
  symbol:   variable ItemStackStringTranslator
  location: class ColoringMaterialsManager
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:320: error: cannot fi
nd symbol
                                                new GsonRecipeConversion(RECIPET
YPEBRUSH, RecipeStringTranslator.toString(map, "  #", " % ", "$  ", '#', Blocks.
wool, '%', RECIPEENTRYMATERIAL, '$', "stickWood"))

          ^
  symbol:   variable RecipeStringTranslator
  location: class ColoringMaterialsManager
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:415: error: cannot fi
nd symbol
                                                                        if(ItemS
tackStringTranslator.isValidItemstack(ing.value)){
                                                                           ^
  symbol:   variable ItemStackStringTranslator
  location: class ColoringMaterialsManager
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:416: error: cannot fi
nd symbol

RGBA rgba = recognizeColorToRGBA(ItemStackStringTranslator.fromString(ing.value)
);

                                 ^
  symbol:   variable ItemStackStringTranslator
  location: class ColoringMaterialsManager
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:422: error: method av
erage in class AdvancedMathUtils cannot be applied to given types;
                                                                mat.color = Adva
ncedMathUtils.average(r[0], ArrayUtils.subarray(r, 1, r.length)) + ":" + Advance
dMathUtils.average(g[0], ArrayUtils.subarray(g, 1, g.length)) + ":" + AdvancedMa
thUtils.average(b[0], ArrayUtils.subarray(b, 1, b.length));

             ^
  required: double,double[]
  found: int,int[]
  reason: varargs mismatch; int[] cannot be converted to double
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:422: error: method av
erage in class AdvancedMathUtils cannot be applied to given types;
                                                                mat.color = Adva
ncedMathUtils.average(r[0], ArrayUtils.subarray(r, 1, r.length)) + ":" + Advance
dMathUtils.average(g[0], ArrayUtils.subarray(g, 1, g.length)) + ":" + AdvancedMa
thUtils.average(b[0], ArrayUtils.subarray(b, 1, b.length));


          ^
  required: double,double[]
  found: int,int[]
  reason: varargs mismatch; int[] cannot be converted to double
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:422: error: method av
erage in class AdvancedMathUtils cannot be applied to given types;
                                                                mat.color = Adva
ncedMathUtils.average(r[0], ArrayUtils.subarray(r, 1, r.length)) + ":" + Advance
dMathUtils.average(g[0], ArrayUtils.subarray(g, 1, g.length)) + ":" + AdvancedMa
thUtils.average(b[0], ArrayUtils.subarray(b, 1, b.length));



       ^
  required: double,double[]
  found: int,int[]
  reason: varargs mismatch; int[] cannot be converted to double
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:463: error: no suitab
le constructor found for RGBA(int,int,int)
                                                                material = new C
oloringToolMaterial(mat.name, mat.durability, new RGBA(Integer.parseInt(s[0]), I
nteger.parseInt(s[1]), Integer.parseInt(s[2])), mat.bufferMultiplier);

                                              ^
    constructor RGBA.RGBA() is not applicable
      (actual and formal argument lists differ in length)
    constructor RGBA.RGBA(int,int,int,int) is not applicable
      (actual and formal argument lists differ in length)
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringMaterialsManager.java:470: error: cannot fi
nd symbol
                                                        map.put(r.name, ItemStac
kStringTranslator.fromStringAdvanced(r.value));
                                                                        ^
  symbol:   variable ItemStackStringTranslator
  location: class ColoringMaterialsManager
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringToolMaterial.java:20: error: no suitable co
nstructor found for RGBA(int)
                this(n, d, new RGBA(h), b);
                           ^
    constructor RGBA.RGBA() is not applicable
      (actual and formal argument lists differ in length)
    constructor RGBA.RGBA(int,int,int,int) is not applicable
      (actual and formal argument lists differ in length)
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\material\ColoringToolMaterial.java:24: error: cannot find sy
mbol
                return rgba.argb();
                           ^
  symbol:   method argb()
  location: variable rgba of type RGBA
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\tool\ColoringTool.java:284: error: cannot find symbol
                        return getCurrentRGBA(itemstack).argb();
                                                        ^
  symbol:   method argb()
  location: class RGBA
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\color\tool\ColoringToolsManager.java:51: error: cannot find symbol

                                                        GameRegistry.addRecipe(R
ecipeStringTranslator.fromString(new ItemStack(item), e.getValue().getValue(), C
oloringMaterialsManager.getRecipe(e.getValue().getKey(), provider.getRecipeType(
))));
                                                                               ^

  symbol:   variable RecipeStringTranslator
  location: class ColoringToolsManager
C:\my\mcmodding\mods\Colourful-Blocks\build\sources\java\code\elix_x\coremods\co
lourfulblocks\gui\GuiSelectColor.java:137: error: no suitable constructor found
for RGBA(int,int,int)
                        ColourfulBlocksBase.net.sendToServer(new ColorChangeMess
age(new RGBA(r, g, b)));

    ^
    constructor RGBA.RGBA() is not applicable
      (actual and formal argument lists differ in length)
    constructor RGBA.RGBA(int,int,int,int) is not applicable
      (actual and formal argument lists differ in length)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
24 errors
1 warning
:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 13.467 secs

C:\my\mcmodding\mods\Colourful-Blocks>

Apearently, gradle does not read linked classes? What can i do to avoid that?

Because when developping several mods simulatenously, and applying changes to core (because there's common classes), it will become very problematic syncing core code in multiple places...

 

Thanks for help!

If you have any questions - just ask!

Posted

Unless you include your core mod via Gradle (easiest would be using a compiled jar and potentially shading it), Gradle has no idea if they exist.

I understand that, but how can i say to gradle "grab more class files there"? Or i could use shaded jar method, but i don't know how to do this either.

Posted

First of all, coremod has classes, that my mods use to interact with each other in case they are installed.

Second of all, coremod is a mod and not just common classes, as for their functionality it has to setup things at runtime.

So i cannot use shading, because if i use it - minecraft will just crash, because

new mod1.lib.CommonClass()

is not

new mod2.lib.CommonClass()

.

I'll try to google for other solutions myself, but anymore ideas?

Posted

I succesfully did it! And it is pretty easy actually.

Here's little tutorial of how to add eclipse's linked sources to gradle:

-Now open build.gradle file of project.

-In

dependencies

add

	compile files("linkedSourceClassFilesDir"){
	 builtBy 'compile'
}

and replace

linkedSourceClassFilesDir

with folder containing compiled class files of linked source. In case when linked source is another mod, they are in

modDir/bin

. In my case, it is

C:/my/mcmodding/mods/excore/1.7.10/bin

.

-Somewhere else in build.gradle (in the end, or just below

dependencies

) add this line:

task compile {}

.

-How does this work?

--In dependiencies you tell gradle, to take files in

linkedSourceClassFilesDir

and compile them by running task

compile

--

task compile

line is compile task itself which is going to be run to compile files.

--But because we take already compiled class files, there's no need of doing anything with them. That's why

task compile

is empty.

-Here's example of what you should end up with:

dependencies {
compile files("C:/my/mcmodding/mods/excore/1.7.10/bin"){
	 builtBy 'compile'
}
}

task compile {}

 

Thanks for help everybody!

  • 1 month later...
Posted

You could also add the compiled library mod jar as a compile time dependency and just not shade it.

 

Bit of a bump here, but you you mind providing an example of this? I'm working with sqlite-jdbc and I've tried a few ways to compile it with a mod unsuccessfully so far, it downloads from maven repos if I include it in the buildscript dependencies but beyond that I'm not sure where it downloads to; I've no issue with Java but Gradle is a new one for me. I do also have the sqlite-jdbc jar file but again, gradle is alien right now.

 

Using the above from Elix compiles and runs but the server crashes as soon as it hits the code requiring JDBC with a classNotFound exception, as expected really.. And of course the mod works if I include JDBC in the Mods directory on the server but I'm trying to avoid that.

That is not dead which can eternal lie,

and with strange aeons even death may die.

Posted

You could also add the compiled library mod jar as a compile time dependency and just not shade it.

 

Bit of a bump here, but you you mind providing an example of this? I'm working with sqlite-jdbc and I've tried a few ways to compile it with a mod unsuccessfully so far, it downloads from maven repos if I include it in the buildscript dependencies but beyond that I'm not sure where it downloads to; I've no issue with Java but Gradle is a new one for me. I do also have the sqlite-jdbc jar file but again, gradle is alien right now.

 

Using the above from Elix compiles and runs but the server crashes as soon as it hits the code requiring JDBC with a classNotFound exception, as expected really.. And of course the mod works if I include JDBC in the Mods directory on the server but I'm trying to avoid that.

What i was doing is compiling required dependency which was developed in separate folder.

What you is trying to do is to compile optional dependency. Independently of how you compile it, you either make it required or use reflection and

@Optional

annotations everywhere where referencing it.

Posted

Bit of a bump here, but you you mind providing an example of this?

 

http://forgegradle.readthedocs.org/en/FG_1.2/user-guide/shading/

 

If you do shade it into your jar, you need to read the project's license and make sure you have permission to redistribute it before doing so.

 

What i was doing is compiling required dependency which was developed in separate folder.

What you is trying to do is to compile optional dependency. Independently of how you compile it, you either make it required or use reflection and

@Optional

annotations everywhere where referencing it.

 

@Optional

wouldn't work because sqlite-jdbc isn't a mod.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Posted

Bit of a bump here, but you you mind providing an example of this?

 

http://forgegradle.readthedocs.org/en/FG_1.2/user-guide/shading/

 

If you do shade it into your jar, you need to read the project's license and make sure you have permission to redistribute it before doing so.

 

What i was doing is compiling required dependency which was developed in separate folder.

What you is trying to do is to compile optional dependency. Independently of how you compile it, you either make it required or use reflection and

@Optional

annotations everywhere where referencing it.

 

@Optional

wouldn't work because sqlite-jdbc isn't a mod.

 

Yeah luckily I'm able to distribute this under their terms for non-profit reasons and I think maybe a reference to their original jar file in the manifest. I've managed to shade it in using a method (given a lot of reading) that was actually fairly simple and obvious once you showed me it:

 

Taken and studied from the link provided:

configurations {
shade
compile.extendsFrom shade
}

dependencies {
shade 'org.xerial:sqlite-jdbc:3.8.11.2'
}

jar {
configurations.shade.each { dep ->
	from(project.zipTree(dep)) {
		exclude 'META-INF', 'META-INF/**'
	}
}
}

 

The only issue I have now is that the server acts as though it's not there; I'm assuming that since the shading happens at the reobfuscation period that references to sqlite-jdbc use the regular package names whilst developing so I'm not sure where to stand with this.. Thanks for the poke in the right direction so far, though

That is not dead which can eternal lie,

and with strange aeons even death may die.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.