I am attempting to create a gradle task which runs TexturePacker according to the instructions here. (Note that I am using Android Studio and its directory structure rather than Eclipse.) I first added the following to the Android Studio project's build.gradle
:
import com.badlogic.gdx.tools.texturepacker.TexturePacker
task texturePacker << {
if (project.ext.has('texturePacker')) {
logger.info "Calling TexturePacker: "+texturePacker
TexturePacker.process(texturePacker[0], texturePacker[1], texturePacker[2])
}
}
This gave the error
unable to resolve class com.badlogic.gdx.tools.texturepacker.TexturePacker
Moving the texturePacker
task to build.gradle
in the desktop project produces the same error. According to http://www.reddit.com/r/libgdx/comments/2fx3vf/could_not_find_or_load_main_class_texturepacker2/, I also need to add compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
to the root build.gradle
under the desktop project's dependencies. When I do so, I still get the same error.
So I have several questions:
Where is the correct place for the
texturePacker
task? Whichbuild.gradle
do I put this in?How do I solve the dependency issue and the
unable to resolve class...
error?How do I specify the input and output directories and the atlas file when running this with gradle? (Assuming the first two questions are solved.)
I got it working by adding gdx-tools to my buildscript dependencies:
by doing this, my desktop's build.gradle was able to import the texture packer class:
please note that your desktop project's ext will need to have texturePacker defined: