Git Dependency Resolver For Unity by mob-sakai - 20

SDK

This plugin resolves git url dependencies in the package for Unity Package Manager. You can use a git url as a package dependency!

Unity 2018.3.0f2MIT LicenseUpdated 64 days agoCreated on May 15th, 2019
Go to source

Git Dependency Resolver For Unity

This plugin resolves git url dependencies in the package for Unity Package Manager.
You can use a git url as a package dependency!

logo

PRs Welcome

<< Description | Install | Usage | Demo | Development Note >>

What’s new? See changelog

Do you want to receive notifications for new releases? Watch this repo

Support me on Patreon! become_a_patron





Description

In Unity 2018.3, the Unity Package Manager (UPM) supported Git. 😃
https://forum.unity.com/threads/git-support-on-package-manager.573673/

This update allows us to quickly install packages on code hosting services such as GitHub.

However, UPM does not support git urls as dependencies in the package. 😦

[ package-a/package.json ]
{
  "name": "com.coffee.package-a",
  "version": "0.1.0",
  "dependencies": {
    "com.coffee.core-a" : "https://github.com/mob-sakai/GitPackageTest#core-a-0.1.0"
  }
}

console


This plugin resolves git url dependencies in the package for Unity Package Manager.

You can use a git url as a package dependency!

Features

  • Easy to use: just install
  • Resolve git url dependencies in packages
  • Uninstall unused packages that is installed by this plugin
  • Support GitHub, Bitbucket, GitLab, etc.
  • Support private repository
  • Support Unity 2019.1+
  • Support .Net 3.5 & 4.x
  • Update package with a specific tag/branch
  • Deterministic package installation
  • Refer to no files from the Library folder

Notes

From: https://forum.unity.com/threads/git-support-on-package-manager.573673/page-3#post-4552084

There is no conflict detection and/or resolution algorithm. The lastest package found with the same name is used. This is not how the package manager resolve dependency (See https://docs.unity3d.com/Manual/upm-conflicts-auto.html).

In Unity’s algorithm, package conflicts are resolved by “dependency-level from root”.
The all packages resolved by this plugin are “dependency-level=1”.
Therefore, in some cases, the package of the intended version may not be installed.

For example, in the case of a project with a dependency graph like this:

project (root)
 ├ package A: 1.0.0 
 │  └ package X: 2.0.0
 └ package B: 1.0.0
    └ package C: 2.0.0
       └ package X: 2.0.1

This plugin’s algorithm

Install -> A: 1.0.0, B: 1.0.0, C: 2.0.0, X: 2.0.1

Unity’s algorithm Install -> A: 1.0.0, B: 1.0.0, C: 2.0.0, X: 2.0.0





Install

Find Packages/manifest.json in your project and edit it to look like this:

{
  "dependencies": {
    "com.coffee.git-dependency-resolver": "https://github.com/mob-sakai/GitDependencyResolverForUnity.git#1.1.2",
    ...
  }
}

To update the package, change #{version} to the target version.
Or, use UpmGitExtension to install or update the package.

Requirement
  • Unity 2018.3 or later





Usage

  • If dependencies are not resolved successfully, try the following:
    • Reopen the project.
    • Delete Library directory in the project.
      library
  • When Unity Package Manager Error window is opens, click Continue.
    window
  • Use SemVer as a tag or branch name.
    eg. 1.0.0, 0.5.0-preview10, 0.1.0-alpha+daily5





Demo

https://github.com/mob-sakai/UnityGitDependencyTest





Development Note

Develop a package for UPM

The branching strategy when I develop a package for UPM is as follows.

Branch Description ‘Assets’ directory
develop Development, Testing Included
upm(default) Subtree to publish for UPM Excluded
{tags} Tags to install using UPM Excluded

Steps to release a package:

  1. Develop your package project on develop branch and update version in package.json.
  2. Split subtree into ump branch.
    git subtree split --prefix=Assets/YOUR/PACKAGE/DIRECTRY --branch upm
  3. Tag on ump branch as new version.
  4. That’s all. 😃

For details, see https://www.patreon.com/posts/25070968.





License

Author

mob-sakai
become_a_patron

See Also

Show all projects by mob-sakai