2020-05-06 15:41:14 +02:00
---
2020-05-06 21:36:20 +02:00
title: Migrate a v1 plugin
2020-05-06 15:41:14 +02:00
---
2020-03-09 08:01:43 +01:00
2020-06-11 07:16:31 +02:00
Before starting, make sure to read the [Plugin Development ](../plugin-development ).
2020-03-09 08:01:43 +01:00
To migrate an existing SCM-Manager 1.x Plugin, you have to do the following steps:
2020-04-01 08:17:05 +02:00
### Maven (pom.xml)
2020-03-09 08:01:43 +01:00
* create a separate branch for the new version
* It might be helpful to start and review the old version of the plugin via `mvn scmp:run` for later reference.
2020-04-22 08:57:36 +02:00
* Import .gitignore & .editorconfig from SCMM
2023-11-29 18:14:03 +01:00
* You might run the build once and review and fix SCMMv1 deprecation warnings. SCMMv2 gets rids of all deprecated
classes.
* update the version of the parent artifact (sonia.scm.plugins:scm-plugins) to the minimum version of SCM-Manager 2 you
are planning for your plugin
* change the packaging type of your plugin to smp
2020-03-09 08:01:43 +01:00
* remove the sonia.scm.maven:scm-maven-plugin from the pom
* remove servlet-api from the list of dependencies (not always the case)
```diff
diff -r a988f4cfb7ab pom.xml
--- a/pom.xml Thu Dec 10 20:32:26 2015 +0100
+++ b/pom.xml Tue Oct 30 11:49:35 2018 +0100
@@ -6,13 +6,14 @@
<parent>
<artifactId>scm-plugins</artifactId>
<groupId>sonia.scm.plugins</groupId>
- <version>1.15</version>
2020-04-22 08:57:36 +02:00
+ <version>2.0.0-rc7</version>
2020-03-09 08:01:43 +01:00
</parent>
<groupId>sonia.scm.plugins</groupId>
<artifactId>scm-mail-plugin</artifactId>
<version>1.6-SNAPSHOT</version>
<name>scm-mail-plugin</name>
+ <packaging>smp</packaging>
<url>https://bitbucket.org/sdorra/scm-mail-plugin</url>
<description>
The mail plugin provides an api for sending e-mails.
@@ -28,13 +29,6 @@
<dependencies>
- <dependency>
2023-11-29 18:14:03 +01:00
- <groupId>jakarta.servlet</groupId>
2020-03-09 08:01:43 +01:00
- <artifactId>servlet-api</artifactId>
- <version>${servlet.version}</version>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.codemonkey.simplejavamail</groupId>
<artifactId>simple-java-mail</artifactId>
<version>2.4</version>
@@ -52,18 +46,6 @@
2023-11-29 18:14:03 +01:00
<jakartamail.version>1.4.7</jakartamail.version>
2020-03-09 08:01:43 +01:00
</properties>
- <build>
- <plugins>
-
- <plugin>
- <groupId>sonia.scm.maven</groupId>
- <artifactId>scm-maven-plugin</artifactId>
- <version>1.22</version>
- </plugin>
-
- </plugins>
- </build>
<repositories>
<repository>
```
2020-04-01 08:17:05 +02:00
### Plugin Descriptor (src/main/resources/META-INF/scm/plugin.xml)
2020-03-09 08:01:43 +01:00
2023-11-29 18:14:03 +01:00
* add the following dtd to the top of the
plugin.xml: `<!DOCTYPE plugin SYSTEM "https://download.scm-manager.org/dtd/plugin/2.0.0-01.dtd">`
2020-03-09 08:01:43 +01:00
* add an scm-version element with the value 2 to the plugin.xml
* remove resources and packages from plugin.xml
```diff
diff -r a988f4cfb7ab src/main/resources/META-INF/scm/plugin.xml
--- a/src/main/resources/META-INF/scm/plugin.xml Thu Dec 10 20:32:26 2015 +0100
+++ b/src/main/resources/META-INF/scm/plugin.xml Tue Oct 30 11:55:15 2018 +0100
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!DOCTYPE plugin SYSTEM "https://download.scm-manager.org/dtd/plugin/2.0.0-01.dtd">
<!--
Copyright (c) 2010, Sebastian Sdorra
@@ -34,6 +35,8 @@
<plugin>
+ <scm-version>2</scm-version>
+
<information>
<author>Sebastian Sdorra</author>
<wiki>https://bitbucket.org/sdorra/scm-manager/wiki/mail-plugin</wiki>
@@ -44,12 +47,4 @@
<min-version>${project.parent.version}</min-version>
</conditions>
- <packages>
- <package>sonia.scm.mail</package>
- </packages>
-
- <resources>
- <script>/sonia/scm/mail/sonia.mail.js</script>
- </resources>
2020-04-22 08:57:36 +02:00
+ <resources>
+ <script>assets/scm-mail-plugin.bundle.js</script>
+ </resources>
2020-03-09 08:01:43 +01:00
</plugin>
```
### Java sources (src/main/java)
* try to compile the sources: `mvn compile`
2020-06-11 07:16:31 +02:00
* fix problems (TODO more help here)
2023-11-29 18:14:03 +01:00
* Remove XML accept headers from REST Resource classes -> SCMMv2 supports JSON only
* Migrate REST Resources (e.g. `v2` , add to Index Resource, Update Links) - See core plugins Git, Hg, Svn,
e.g. [`GitConfigResource` ](https://github.com/scm-manager/scm-manager/blob/develop/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitConfigResource.java )
2020-03-09 08:01:43 +01:00
### UI (src/main/js, src/main/webapp)
* remove all SCM-Manager 1.x ui code from resource directory (src/main/resources)
2020-04-22 08:57:36 +02:00
* create `package.json` with the following content (replace name-of-plugin with the name of your plugin):
2020-03-31 17:28:30 +02:00
2020-03-09 08:01:43 +01:00
```json
{
"name": "@scm -manager/name-of-plugin",
2024-09-24 09:42:07 +02:00
"license": "AGPL-3.0-only",
2020-04-22 08:57:36 +02:00
"main": "src/main/js/index.tsx",
2020-03-09 08:01:43 +01:00
"scripts": {
2023-11-29 18:14:03 +01:00
"build": "ui-scripts plugin",
"watch": "ui-scripts plugin-watch",
"postinstall": "ui-plugins postinstall"
2020-03-09 08:01:43 +01:00
},
"dependencies": {
2023-11-29 18:14:03 +01:00
"@scm -manager/ui-plugins": "2.0.0"
2020-03-09 08:01:43 +01:00
}
}
```
2020-03-31 17:28:30 +02:00
2020-04-22 08:57:36 +02:00
* create a `tsconfig.json` with the following content:
```json
{
"extends": "@scm -manager/tsconfig",
"include": [
"./src/main/js"
]
}
```
2020-03-09 08:01:43 +01:00
* run `mvn process-resources` to install the required JavaScript libraries
* create new ui at `src/main/js` (for JavaScript code) and `src/main/webapp` (for static files) (TODO more help)
* Start SCM-Manager with the plugin using `mvn run` - features hot reloading of UI & Java Code.
In order for Java classpath resources to be reloaded in IntelliJ, pressing compile is necessary.
Some more hints:
2023-11-29 18:14:03 +01:00
* For Configuration UIs
use [`ConfigurationBinder` ](https://github.com/scm-manager/scm-manager/blob/develop/scm-ui/ui-components/src/config/ConfigurationBinder.tsx )
- See core plugins Git, Hg, Svn,
e.g. [scm-git-plugin/index.ts ](https://github.com/scm-manager/scm-manager/blob/develop/scm-plugins/scm-git-plugin/src/main/js/index.ts )
.
2020-03-09 08:01:43 +01:00
Note that `readOnly` property checks if update link is returned by REST resource
2023-11-29 18:14:03 +01:00
* Don't forget [i18n for Plugins ](../i18n-for-plugins )
2020-03-09 08:01:43 +01:00
# Further reading
2020-03-31 17:28:30 +02:00
2020-06-11 07:16:31 +02:00
* [UI Extensions ](../../ui-extensions ) - Extend the SCM-Manager UI
2023-11-29 18:14:03 +01:00
* [scm-manager/ui-components ](https://github.com/scm-manager/scm-manager/tree/develop/scm-ui/ui-components ) - Reusable
UI components within SCM-Manager
* [smp-maven-plugin ](https://github.com/scm-manager/smp-maven-plugin ) - Plugin that facilitates efficient plugin
development for SCMM