#TodayILearned: Gradle for #EclipseIDE is quite stubborn when it comes to adding a JVM container to one's #Java projects.

Every time I update the JVM (in this case to 1.8.0_152) I need to tell Eclipse and Gradle which JVM to run, and which JVM to apply to my Java projects. When we tell Gradle to apply the java plug-in to a project, it automatically inserts some random JRE that isn't defined anywhere. It most certainly isn't the SDK that my projects need.

To solve this, we can set the Eclipse classpath from the Gradle build script, after we tell Gradle to apply the eclipse plug-in to a project. It looks like this:

def sdkName = 'SDK 1.8.0_152'
def sdkContainerPrefix = 'org.eclipse.jdt.launching.JRE_CONTAINER'
def sdkContainer = sdkContainerPrefix + '/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/' + sdkName

eclipse.classpath.containers sdkContainer

And then Gradle nicely adds TWO (2) JVM containers: the random JRE it defined in some unknown location, plus the SDK we just specified.

(Note: the SDK specified above bears the name 'SDK 1.8.0_152'. This is a custom name chosen by me. It is the same as I chose in Eclipse' preferences for Java -> Installed JREs. In my set-up, it is the only JRE I specified, and therefore the default.)

To fix this, with Gradle 4.3.1, we get to undo part of what Gradle's java plug-in does. Instead of the above instruction, we do this:

project.afterEvaluate {
project.eclipse.classpath {
containers.removeAll { it.startsWith(sdkContainerPrefix) }
containers.add(sdkContainer)
}
}

And that, my fellow Gradlers, is completely ridiculous.

Why on earth can we specify a sourceCompatibility and a targetCompatibility if not to specify a JVM version?

I don't know.

Happy Gradling!

I just installed Android Studio on Windows 10, and tried to create my first App ("Hello World") from the Studio website. The program gets stuck (but computer remains responsive) at the "Gradle Build" step. I saw another post on this topic, referring to firewall issues, but no resolution. I turned off my firewall, but the problem persisted. Also, I looked on Task Manager and the Android Studio task was using 83% of memory (>480MB). Many thanks in advance if any ideas!

#TodayILearned how to get Gradle to deploy my application distributions and their dependencies to target application servers and library repositories.

It has been a missing piece in the automation of my deployments. Gradle already generates the application distributions, but the deployment there-of still was a manual affair.

My applications usually are grouped in suites. All applications in a suite share the same base library. That gets assembled and deployed first. Both happen via Gradle. For deployment, I use Gradle's uploadArchives task, from its Java-Library plug-in. This is my script:

uploadArchives {
repositories {
flatDir {
dirs localLibFolder
}
flatDir {
dirs sourceRepository
}
flatDir {
dirs targetLibFolder
}
}
}

My script fills in folder paths for the parameters localLibFolder, targetLibFolder, and sourceRepository.

The script also uses that targetLibFolder in my custom task of type Copy, that generates the individual application distributions. Each app will be distributed in a handful of flavors, and they need to know where to find the libraries on which they depend. Those are stored in the targetLibFolder.

Next, another custom task of type Copy depends on my custom task generateDistribution, and copies the distribution to a target folder on the target app server.

Each distribution and deployment gets timestamped, so multiple versions can exist next to each other.

The last challenge I will solve is how to automatically stop the scheduled task that runs the last version of an app flavor, and create a new scheduled task for the new version. Or maybe update the existing task to point to the new version.

I figured out how to do that in Powershell, but I have yet to incorporate that into my Gradle build script.

Happy Gradling!

#TodayILearned: the Gradle #TasksView for #EclipseIDE sports a little down-pointing triangle. Activate it for a context menu. This sets what the view displays.

For instance, if you set it to Show Task Selectors, then each (sub) project will list all tasks, whether they are available for that project or not. Activating an unavailable task by double-clicking it, will result in a warning.

So instead, set it to Show Project Tasks. That way, each (sub) project will only show those tasks that are available in that project. Activating one of those tasks will execute it.

And finally, the Show All Tasks setting can be used you show tasks you created yourself, if you didn't specify a group.

Happy Gradling!

#TodayILearned: Gradle will happily zip your entire hard drive, only to fail when it runs out of space, but then locks the build cache...

I was experimenting with Gradle's #java plugin. This has an "artifacts" task. Its "archives" property can receive multiple other tasks, like a custom sourcesJar task (type: Jar).

Normally we would use such a task to publish a library's source files. And for a library, the task's "from" typically is set to sourceSets.main.allSource.

However, as I said, I was experimenting.

I wanted to see if this task could be used to zip the contents of the entire project directory, and then publish that to our internal version control safe.

Well.

What I managed to do, was have that Gradle task zip the entire source drive, including the zip file it was creating, recursively.

One can imagine this fails.

And it did.

I am lucky that the machine's IDE and OS live on different disks, otherwise the damage may have been irreparable.

Anyway, what I did, and what you shouldn't do, is tell a custom task of type Jar, that it needs to use project.projectDir as "from".

Happy gradling!

How do I run individual project tasks, when the projects are subprojects in a multi-project configuration, using Buildship for Eclipse?

I know how to run them from the commandline:
$ gradle :subproject:task

That works, but I am more comfortable clicking around in an IDE's GUI.

Buildship for Eclipse shows the individual subproject Gradle Tasks in its Eclipse view (appropriately named "Gradle Tasks"), but when I double-click one to run it (like we can with single-project configurations), Gradle's console output complains that the task doesn't exist.

Well, obviously it does exist, otherwise I couldn't run it from the commandline and I couldn't see it in Buildship's "Gradle Tasks" view.

Has anyone here gotten that to work? Care to share how?

#TodayILearned that Gradle is capable of setting multiple custom #javadoc tags, using options.setTags([a, b, c]), in which a, b, and c stand for individual javadoc tag descriptors like 'default:a:Default:', 'version:a:Version:', etc.

How do I set up a local, offline, Ivy-like dependency repository, from which Gradle can read?

Post has attachment
Looking for a professional GPS Vehicle Tracking Solution?
We have everything you need to take care of you, your family and business. Tracking and Control Services by Precise Automation and Robotics.

Key features:
• Real-time & historical location tracking
• Get alerts Messages
• Easy Monitoring and Convenience to use

Contact us today for more information:
Office: +91-291-2771164
Email: info@preciseautomation.co.in
Website: www.preciseautomation.co.in
#GPS #Realtimelocation #GPSTracking #GPSDevice #tracklocation #fleetmanagement 

Post has attachment
Looking for a professional GPS Vehicle Tracking Solution?
We have everything you need to take care of you, your family and business. Tracking and Control Services by Precise Automation and Robotics.

Key features:
• Real-time & historical location tracking
• Get alerts Messages
• Easy Monitoring and Convenience to use

Contact us today for more information:
Office: +91-291-2771164
Email: info@preciseautomation.co.in
Website: www.preciseautomation.co.in
#GPS #Realtimelocation #GPSTracking #GPSDevice #tracklocation #fleetmanagement 
Wait while more posts are being loaded