October 1, 2015

How to Share Components or Common Code With Import+ Paths

Streams
Traceability

Ever wondered how to reuse a software component or share common code? There are a variety of methods and workflows in Perforce Helix that support this concept of Component-Based Development (CBD), including the “Import+” feature for a stream path.

The import path in a stream allows you to share or re-use code and specifies a path of files from outside your current stream depot. Using the import paths in your stream, you can sync these files into your project. However, because the import paths are imported into the stream, you can't make changes and submit them via the stream, nor can you integrate them. Additionally, the import path allows you to re-use code, but you are only able to sync the head revision of the common code that you are importing.

We improved import paths in the 2014.1 release of Helix by adding the ability to include a changelist specifier. With this, the stream's client workspaces will be limited to seeing revisions at that change or lower within that depot path. For example, let’s use this depot path:

import common1/… //depot/common1/...@1000

Now you will have revisions up to changelist 1000 in your stream from the common code.

But that wasn’t enough. Customers also needed the ability to import a common component and modify it within the stream.  So we added the import+ stream path, which functions like a standard import path, enabling you to map a path from outside the stream depot. However, unlike a standard import path, in an import+ path you can submit changes to the files. For example, you can now specify a depot path like this: 

import+ common2/…  //depot/common2/...

This allows me to modify the files in the common2 codebase imported into my stream.

Let’s take a look at import+ paths in action:

Now that I have the import+ path defined for my secure component, I can modify the files within this path:

Once I submit my changelist I see that the secure component has my new revision in the core components stream:

And that’s it! A simple and effective solution for editing my common code. 

Helix offers numerous methods and workflows that support CBD; here are a few resources to give you a taste:

Stay tuned as we continue to add even more functionality in coming Helix releases.