Putting a Project under Perforce Control
When you create the project, make sure that the directory where its files reside
is under the client root of the Perforce workspace you intend to use.
To put a project under Perforce control, perform the following steps:
- In the Resource perspective's Navigator pane, right-click the project and
choose Team>Share Project
The Share Project dialog
is displayed.
- From the Repository Type list, choose Perforce and click Next.
The Server Connection Settings dialog is displayed.
- Specify the required settings as follows:
- Port: the name and port of the Perforce server where you want to
store project files, as follows: host:port
- User: your Perforce user name. If the user has a password, enter
it in the Password field.
- Client Workspace: the name of the client workspace configured on
your computer. (Important: project files must reside under the specified
client workspace's root directory.)
- Charset: set this field only if your server is running in
Unicode mode. Consult your Perforce administrator for the required information.
- Click Finish.
- In the Navigator pane, right-click the project folder and choose Team>Open
for Add... The Add dialog is displayed, listing the project files
you are adding to the depot, and the changelist in which you are adding them.
- To select a different changlist, choose the desired changelist from the
Add to Change drop-down list.
- Click OK.
- To submit the changelist, right-click it in the Perforce Pending Changelists
pane and choose Submit... The Perforce Change Specification
dialog is displayed.
- Enter a description and click OK. The project files are added to the depot
according to the settings you specified.
If you subsequently add files to the project, you must also add them to Perforce
(steps 6 through 10 above, or use the corresponding Perforce task created in
the Tasks View). When you add files to a project, a new Perforce task is appended
to the Tasks View, with the description "Local addition not under Perforce
control". To open the file for add and thereby remove the task:
- Right-click on the task.
- Choose Quick Fix
- Choose the Open for Add fix. (To exclude the file from Perforce control
and remove the task, choose Exclude from Source Control.)
To exclude files from source control: in the directory where the files
reside, create a text file named .p4ignore and enter the directories and file
names you want to exclude. When you specify a directory, all its subdirectories are ignored. You cannot use wildcards in .p4ignore
files.
To change server settings for a project that is already under Perforce
control, right-click the project, choose Properties, and click Perforce.
NOTE: P4WSAD does not support deleting, moving, renaming, or refactoring
linked resources (files and folders that are stored in locations in the file
system outside of the project's location).
Excluding Files from Source Control
To conserve space in the repository and to keep changelists small, you can exclude individual files or file types (for example, build or release artifacts) from source control. Eclipse excludes a standard set of such files if you use the default Eclipse build output folder setup and global file type ignore features. If you need to go beyond the default—for example if you use a different builder or build output setup, or you intersperse temporary or other non-essential files with Perforce-managed files in your workspace—you can customize file exclusions using the approaches described in this section. Note that the different exclusion approaches operate independently. For example, if you exclude a file type using a .p4ignore file, you cannot override the exclusion by modifying the list of ignored resources in Preferences.
In general:
- To exclude on a per-filetype basis, use Preferences > Team >CVS > Ignored Resources
- To exclude build/test artifacts, set the Derived property
- To exclude specific files and folders, use Team >Exclude from Source Control or manually-maintained .p4ignore files.
Following are details:
- To exclude files in a project based on file type (for example, to exclude all ".bak" or ".jar" files in a project from Perforce management), choose Preferences > Team >CVS > Ignored Resources and check the file types you want to exclude. (Despite the "CVS" menu item name, these settings are processed by P4WSAD). For more details, refer to Eclipse online help.
- To exclude a specific set of folders or files, right-click the files or folders, choose Properties, and check "Derived." P4WSAD ignores derived files and folders, including (recursively) subfolders in derived folders.
Note that the Derived property is intended to mark temporary or volatile folders and files that are derived from or created by a build or test process. This mechanism is not the best choice for the general case of exclusion. By default, Eclipse marks compiled .class files and associated output folders as derived, if you use the standard Eclipse layout and build features to define the output folders. However, if you're using non-standard build paths, mechanisms, folders, etc., you might need to manually enable the derived property for these objects.
- For temporary exclusion or exclusions that are not addressed by the preceding approaches, right-click the file or folder and choose Team > Exclude from Source Control.
This P4WSAD Exclude from Source Control feature stores exclusions in a .p4ignore file, similar to CVS's .cvsignore feature. The .p4ignore file is a text file that specifies excluded files and folders that reside in its containing folder and any subfolders (recursively). P4WSAD searches up the project folder hierarchy looking for .p4ignore files, and stops at the first .p4ignore file entry that matches a specific file or folder. (Unlike the CVS ignore facility, Perforce does not honor .p4ignore specifications or other Eclipse ignore features outside P4WSAD). You can create .p4ignore files manually, and you can edit .p4ignore files that were created by P4WSAD. The .p4ignore file itself is typically under source control control, but you can exclude it.
To create a .p4ignore file manually, right-click in the Navigator pane and choose New > File. Enter exclusions and save the file as ".p4ignore" in the folder where you want the exclusions applied. Each entry must be on a separate line in the same format used in .cvsignore files. You can use the * and ? (match any single character) wildcards in .p4ignore files.
To display label decorations for ignored files in the Navigator, choose Preferences > Team > Perforce > Label decorations and check Decorate files/folders contained in .p4ignore.