Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Gradle, how to print out a message in the console / Event Log?

I'm trying to verify that my source and target paths are properly setup when I execute a deploy command.

See the example below:
(copied from: http://eppz.eu/blog/unity-android-plugin-tutorial-2/)

android.libraryVariants.all { variant ->     // Task names.     String variantName = "${variant.name.capitalize()}"; // Like 'Debug'     String deployTaskGroup = "plugin";     String deployTaskName = "deploy${variantName}PluginArchive"; // Like 'deployDebugPluginArchive'     String dependencyTaskName = "assemble${variantName}"; // Like 'assembleDebug'     // Source.     String sourceAARFolder = "${buildDir.getPath()}/outputs/aar/";     String sourceAARName = "${project.name}-${variant.name}.aar";     // Target.     String targetAssetFolder = "Assets/Plugins/My Plugin";     String targetAARFolder = "${rootDir.getPath()}/../../${targetAssetFolder}"; // Navigate into 'Assets'     String targetAARName = "My Plugin Android.aar"; // The form you ship your plugin      String targetProjDir = System.env.UNITY_PROJECT; // <-- Need to confirm this line!     //Log.i(targetProjDir); //??????????? something like this?      // Create task.     task(deployTaskName, dependsOn: dependencyTaskName, type: Copy) {         from(sourceAARFolder)         into(targetAARFolder)         include(sourceAARName)         rename(sourceAARName, targetAARName)     }.group = deployTaskGroup; } 

Is there any way to display the above targetProjDir string variable to some sort of console, or the Event Log in Android Studio (assuming that is it's console's name)?

like image 591
chamberlainpi Avatar asked Nov 30 '16 01:11

chamberlainpi


People also ask

How do I view gradle logs?

View -> Tool Windows -> Build. There is small "ab" button on the left panel. All gradle logs for current build are there.

How do I open the console in gradle?

Go to Gradle console -> Gradle icon that says Execute Gradle task -> a pop-up opens -> attach your project -> write the task in the second field -> ok. Show activity on this post. Click "View" option top on the Android studio then click "Tool Windows" after "Gradle"; that's it.

How do I create a test report in gradle?

How to generate a Test Report. Gradle generates a Test Report automatically when it runs the entire Test Suite. To do the same, run ./gradlew test (or gradlew. bat test from Windows), or run the test Gradle task from your IDE.


1 Answers

Gradle utilizes a logging framework. You can log messages to that. By default, only log level lifecycle and above are shown, but you can log at other levels such as debug and info.

To log at debug level (visible with builds using gradle --debug or lower)

project.logger.debug('my debug message') 

To log at info level (visible with gradle --info builds and lower)

project.logger.info('my info message') 

To log at lifecycle level (visible by default)

project.logger.lifecycle('my message visible by default') 
like image 189
JBirdVegas Avatar answered Sep 22 '22 17:09

JBirdVegas