Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Papyrus/Code Standards"

(Automatic check)
 
(22 intermediate revisions by 8 users not shown)
Line 1: Line 1:
=Coding rules for Papyrus plug-ins and features=
+
= Coding rules for Papyrus plug-ins and features =
  
These rules apply to all plug-ins and features developed for the Papyrus Eclipse project, and distributed under the EPL licence.
+
These rules apply to all plug-ins and features developed for the Papyrus Eclipse project, and distributed under the EPL licence.  
  
==Plug-ins==
 
  
* All plug-ins must compile and run with Java 1.5 (''Execution Environment = J2SE-1.5'')
+
==Features and Plugins==
* Plug-in provider : ''Eclipse Modeling Project''
+
We prefer when the Bundle-Name and Bundle-Vendor fields are externalized in the properties file.
* Version :
+
So we expect a file bundle.properties (or sometimes renamed into plugin.properties) for Plug-In, and a file feature.properties for Feature.  
** Juno : ''0.9.2.qualifier''
+
A such file must be embedded in the binary build, so you must check in the ''Build Configuration'' tab that the file is selected.
** Kepler : ''0.10.0.qualifier''
+
* Plug-in name : must end with (Incubation). e.g. ''Papyrus Backbone (Incubation)''
+
* Plug-in ID : must start with org.eclipse.papyrus
+
* Plug-in dependencies must not be re-exported
+
* Dependencies to Papyrus plug-ins must match the current version (e.g. depend on ''oep.infra.core 0.9.2'' instead of ''oep.infra.core'')
+
* The build.properties file describes the files that '''must''' be included at runtime. It is important to fill it properly, so that plug-ins can work correctly once installed. Especially, you should probably always include the following files and folders (When they exist), in the "Binary build" category:
+
** META-INF/
+
** about.html
+
** icons/, images/, resources/, models/, etc. (All folders containing runtime resources)
+
** plugin.properties
+
** plugin.xml
+
** schema/
+
* Do '''not''' include the following files:
+
** .classpath
+
** .project
+
** bin/, src/, src-gen/, custom-src/
+
** build.properties
+
* The ''Source build'' category '''must''' contain the following file:
+
** about.html
+
* Optionnally, it may contain the following files:
+
** .classpath
+
** build.properties
+
* It '''must not''' contain the following:
+
** src/, src-gen/, custom-src/
+
** All files and directories which are already contained in the "Binary build" category (Except about.html which must be contained in both Binary and Source builds)
+
  
==Java classes==
+
== Features  ==
  
* All APIs must be documented with JavaDoc comments. Automatic generation of JavaDoc comments may help, but the automatically generated comments are '''templats'''. They are not sufficient. It is better not to generate javadoc comments than to generate empty comments.
+
*ID:
* Each Java class must contain the Copyright/Licence/Contributor header. e.g.:  
+
**Main Papyrus components: org.eclipse.papyrus.<feature.name>.feature
<source lang="java">/*****************************************************************************
+
***e.g. ''org.eclipse.papyrus.infra.core.feature''
* Copyright (c) 2013 CEA LIST.
+
*Name: Papyrus &lt;Feature Name&gt; 
*
+
**e.g. ''Papyrus Core''
* All rights reserved. This program and the accompanying materials
+
**e.g. ''Papyrus Model2Doc (Incubation)''
* are made available under the terms of the Eclipse Public License v1.0
+
***Incubation plugin and feature have a version lower than 1.0.0
* which accompanies this distribution, and is available at
+
***Here you will find a definition of incubation: [[Development_Resources/Process_Guidelines/What_is_Incubation]]
* http://www.eclipse.org/legal/epl-v10.html
+
*Each feature.xml file must contains:
*
+
**in ''Information Tab -> Copyright Notice'',
* Contributors:
+
*** ''Optional URL'' : ''https://www.eclipse.org/legal/epl-2.0/''
*  Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+
*** ''Copyright'' :
*****************************************************************************/</source>
+
<blockquote>
* You must '''not''' use the standard console output in Papyrus plug-ins. Use the [[Papyrus_Developer_Guide/Papyrus_Log|Papyrus log]] instead
+
Copyright (c) 20XX CEA LIST
 +
<br/>
 +
All rights reserved. This program and the accompanying materials
 +
are made available under the terms of the Eclipse Public License
 +
2.0
 +
<br/>
 +
which accompanies this distribution, and is available at
 +
https://www.eclipse.org/legal/epl-2.0/
 +
<br/>
 +
SPDX-License-Identifier: EPL-2.0
 +
</blockquote>
  
==Features==
+
[[Image:CopyrightNoticeFeature.png|700px|thumb|none]]
  
* ID:
+
** in ''Information Tab -> License Agreement''
** Main Papyrus components: org.eclipse.papyrus.<feature.name>.feature
+
***Check the field ''Shared License'',
*** e.g. ''org.eclipse.papyrus.infra.core.feature''
+
***License Feature ID: ''org.eclipse.license'',
** Extra components: org.eclipse.papyrus.extra.<feature.name>.feature
+
***License Feature Version: ''2.0.2''.
*** e.g. ''org.eclipse.papyrus.extra.marte.feature''
+
* Name: Papyrus <Feature Name> (Incubation)
+
** e.g. ''Papyrus core (Incubation)''
+
** e.g. ''Papyrus Marte (Incubation)''
+
* Each feature must contain the files ''epl-v10.html'' and ''license.html'' (February 1 2011)
+
* The build.properties file must contain the following files in the "Binary build" section:
+
** feature.xml
+
** epl-v10.html
+
** licence.html
+
** feature.properties (When available)
+
* The build.properties file must contain the following files in the "Source build" section:
+
** epl-v10.html
+
** licence.html
+
** build.properties (Optional)
+
  
=Tests=
+
[[Image:LicenseAgreementFeature.png|700px|thumb|none]]
  
==Test plug-ins==
+
*The build.properties file must contain the following files in the "Binary build" section:
 +
**feature.properties (When available)
 +
**feature.xml
  
Each plug-in contributed within the Papyrus project must be accompanied with a Test plug-in (And their associated Feature). Each test plug-in must ''at least'' contain a test class so that it can be included to the build/test infrastructure. Of course, the more tests it actually contains, the better...
+
<br>
  
The test plug-ins and features must follow the same rules as the other Papyrus plug-ins.
+
[[Image:Papyrus.Build.properties-selectedOptions.png|1000px|thumb|none]]
  
==Automatic check==
+
<br>
  
Most of these rules are checked automatically when running the Papyrus tests. If you want to check them locally, use the plug-in ''org.eclipse.papyrus.bundles.tests'' (''Run as > Junit plug-in test'' or use the ''*.launch'' file from this plug-in). This plug-in can be retrieved on the Papyrus SVN repository: http://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.papyrus/trunk/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests
+
==Additional information for the build process==
 +
The build process also needs to know where is the license. There are 2 solutions :
 +
===Option 1===
 +
In the main pom.xml file (often in the pom.xml of ''releng/folder''), you must write:  
 +
 
 +
<repositories>
 +
<repository>
 +
<id>license-feature</id>
 +
<url>http://download.eclipse.org/cbi/updates/license/</url>
 +
<layout>p2</layout>
 +
</repository>
 +
</repositories>
 +
 
 +
===Option 2===
 +
Your target platform definition file (tpd) must also contains:
 +
location "http://download.eclipse.org/cbi/updates/license/" eclipse-license {
 +
  org.eclipse.license.feature.group lazy
 +
}
 +
 
 +
[[Category:Papyrus]]

Latest revision as of 10:37, 19 November 2020

Coding rules for Papyrus plug-ins and features

These rules apply to all plug-ins and features developed for the Papyrus Eclipse project, and distributed under the EPL licence.


Features and Plugins

We prefer when the Bundle-Name and Bundle-Vendor fields are externalized in the properties file. So we expect a file bundle.properties (or sometimes renamed into plugin.properties) for Plug-In, and a file feature.properties for Feature. A such file must be embedded in the binary build, so you must check in the Build Configuration tab that the file is selected.

Features

  • ID:
    • Main Papyrus components: org.eclipse.papyrus.<feature.name>.feature
      • e.g. org.eclipse.papyrus.infra.core.feature
  • Name: Papyrus <Feature Name>
  • Each feature.xml file must contains:

Copyright (c) 20XX CEA LIST
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0

CopyrightNoticeFeature.png
    • in Information Tab -> License Agreement
      • Check the field Shared License,
      • License Feature ID: org.eclipse.license,
      • License Feature Version: 2.0.2.
LicenseAgreementFeature.png
  • The build.properties file must contain the following files in the "Binary build" section:
    • feature.properties (When available)
    • feature.xml


Papyrus.Build.properties-selectedOptions.png


Additional information for the build process

The build process also needs to know where is the license. There are 2 solutions :

Option 1

In the main pom.xml file (often in the pom.xml of releng/folder), you must write:

<repositories>
		<repository>
			<id>license-feature</id>
			<url>http://download.eclipse.org/cbi/updates/license/</url>
			<layout>p2</layout>
		</repository>
</repositories>

Option 2

Your target platform definition file (tpd) must also contains:

location "http://download.eclipse.org/cbi/updates/license/" eclipse-license {
 org.eclipse.license.feature.group lazy
}

Back to the top