Android Studio Gradle offline Gradle Cache - gradle

Android Studio Version 3.1.3
Issue:
Gradle wants to re-download dependencies that were previously downloaded
For instance: "No cached version of com.android.support:appcompat-v7:27.1.1 available for offline mode."
It doesn't matter which version I use, it refuses to accept the ones located at "/~.gradle/caches/transforms-1/files-1.1/"
I have specified gradle service directory path (where the downloaded dependencies are) and ticked the "Offline work" option. I've tried using the default gradle distribution and a local gradle distribution "gradle-4.8.1-bin".
Am I missing something?
Does that mean that gradle only uses per-project cache? Do I have to download dependencies every time that I create a new project?
If so, is that a way to use the already downloaded dependencies?
Also, may I ask why does Android Studio has a tick option to "Work offline"? What is it used for?

Related

gradle directory in an Android Studio project

There is a directory called gradle in my Android Studio project. They don't say it should be excluded from version control. What is in this directory?
Update #1.
Android Studio bug. It updates gradle/wrapper/gradle-wrapper.properties every time I run it.
The directory gradle having a Gradle Wrapper inside it
The wrapper is something you should check into version control. By distributing the wrapper with your project, anyone can work with it without needing to install Gradle beforehand.
Even better, users of the build are guaranteed to use the version of Gradle that the build was designed to work with. Of course, this is also great for continuous integration servers (i.e. servers that regularly build your project) as it requires no configuration on the server.
That is why it is not excluded from version control.

Integrating NuGet to existing project

We have a very project, and we decided to build it's core as a set of NuGet dependencies using TeamCity. And now we want to import those NuGet packages to the rest of project.
Core can be updated several times a day, and project must use only the latest version. But when we removed version specification or set it as version="", it still used the old version.
So, we want our project to use the latest libraries on each build. Can you post some recomendations?
If you can rely on just TeamCity you could take a look at the NuGet update options that TeamCity provides. They have build options such as Update packages with help of NuGet update command which you could try.
If you want something similar when you build on a developer's machine then you will need to look at some pre-build step that uses NuGet update.

How do I integrate NuGet into my Bamboo Build Plan?

Our build plans for Sitecore (.Net) websites are currently using Bamboo as the build plan master for continuous integration process. Bamboo supports building a .Net project, and that .Net project contains references to several Sitecore binaries.
I have used NuGet as an artifact repository, mostly because that seemed to be the one most people were using.
So, now that I have a nuget repository, am hosting my own feed, and have added the Nuget package to my project (I just installed the package of binaries I created), what more do I need to do?
Should the build call out something special, or am I done? I guess I'm just nervous that bamboo isn't talking directly to my repository....
In the closest analogy I have, namely a Maven/Archiva combo, the maven plan specifically references the artifacts in archiva, pulling the correct version as needed. Does NuGet do this?
Since there have been some new developments in the NuGet package restore approach, I thought I'd post an update on this topic. We're using Visual Studio 2012. I wanted to be able to run MSBuild and make sure that it would first restore NuGet packages without setting "Package restore" to true in the config. Here's what I did (inspired by https://stackoverflow.com/a/23935892/414376):
Upgraded NuGet in my solution to a version later than 2.7 (2.8.3 in my case; this seems like an optional step)
Installed NuGet.exe on the build server
Added NuGet.exe to my remote agent so that it could be run as a command from Bamboo
Added the NuGet command to my build plan with argument restore (so that the command will be nuget restore); I've placed it right before my MSV Build task.
That was all I needed to get this to work properly according to the latest guidelines.
Nuget 1.4+ supports "Package restore" which embeds a call to an MsBuild task in the project file. When the packages are not available it will automatically restore them while building the project.
I'm sure this is old news, but my packages are in \packages. No amount of "dotnet restore" would work, until I explicitly mentioned the packages folder.
dotnet restore --packages .\packages
restored them!
VS2019. just in case it's version specific.

Is it possible to share huge data between projects when the data is installed by Nuget?

I found that nuget seems to always install packages under the folder of the visual studio project.
It is not feasible for me because the package that I'm going to distribute contains huge amount of data. I don't want to make a copy of that whenever I add that package to a new visual studio project.
I want that data to be shared between projects. Since it is shared, if one project removed that package, the data should stay there until I explicitly tell the system to remove it.
Is there any way that can deal with this kind of problem?
I heard that Maven installs packages in a global location and it doesn't have such a problem. How about using Maven to install .NET libraries, is that possible? What would be the potential problems?
To upload and store your .NET artefacts you'll need a Maven repository manager like Nexus, Artifactory or Archiva. Good news is that these are capable of storing files of any type.
If you don't fancy converting your build process over to Maven, I'd recommend the following answer on using Apache ivy with MSBuild. All Maven clients appear to cache their downloads for use across projects (They're basically intelligent downloaders)
The upcoming 2.0 version of Nexus promises integration with NuGet. I'm expecting better .NET support from Maven in the future.

m2e will not run on server [duplicate]

I'm trying out the next version of Eclipse using the latest milestone build and I'm having an issue getting my Maven project deployed to Tomcat.
Previously in Eclipse 3.6, my project was automatically enabled as a web project when checked out from SVN. I've checked out my project in 3.7 but get nothing indicating it's runnable as a web project (e.g. trying to run the project doesn't give me the usual "Run on Server" option).
What I've installed is Indigo RC4 "Eclipse IDE for Java EE Developers" version. I then added the latest M2E milestone from here. This enabled me to get up and running, check out my project and I seem to be able to build the project fine (which does create my .war file for remote deployment). Still no "Run On Server" options though.
Does anyone have any clues on what I could be missing? I'm guessing it's a Maven & WTP integration plugin but I haven't spotted the right one yet.
Before m2e became an eclipse project the WTP integration shipped with the core module. Now the core module is an eclipse module and the WTP integration is shipped separately. The current Indigo snapshots of m2eclipse-wtp can be found here. I was unable to get any artifacts from this update site however, even though it's listed in the corresponding JIRA issue.
Fortunately, today m2e-wtp was made available through the m2e Marketplace. Just open the eclipse preferences, go to 'Maven' -> 'Discovery' -> 'Open Catalog' and install it. .
It will work with the lastet version, it's just the .project that is not right.
Simply go into the project properties, make the projet faceted.. tick Dynamic Web Module and you'll get run on server as an option after that.
This will enable the "Run on Server" option, however your problems don't finish there as when you then run it, you'll get a 404.
To fix this, go back into project properties, Deployment assembly.
Delete the WebContent entry (and you can delete the folder in the project later too), and make sure you have the src-main-webapp & src-main-resource folders added.
Bingo.. run the app and it should be fine.

Resources