Set up your plugin development project
When you develop your plugin, you will extend classes from the OmegaT project, or call methods. To be able to compile
your project, you need the OmegaT dependencies. You can either stub them, copy them individually, or just include the
entire OmegaT project .jar
file in your project. But you have to make sure these files are not part of the .jar
file that you produce.
Gradle example
An example of how to configure the plugin project in a Gradle project. You can use skeleton project as a project template forked from https://github.com/omegat-org/plugin-skeleton
build.gradle
plugin {
id('java')
id('distribution')
id 'org.omegat.gradle' version '1.5.11'
}
version='1.0.0'
group='your.group.id'
omegat {
version='5.7.1'
pluginClass='org.myorganization.MyFilter'
}
gradle.properties
plugin.name=My Filter Name
plugin.category=filter
plugin.link=https://github.com/omegat-org/plugin-skeleton
plugin.author=My name here.
plugin.description=I describe my plugin here. This plugin does amazing things
plugin.license=GNU General Public License version 3
maven example
An example of how to include OmegaT code to your project in a Maven project, without adding it to the compiled .jar file:
<dependency>
<groupId>org.omegat</groupId>
<artifactId>omegat</artifactId>
<version>5.4.4</version>
<scope>provided</scope>
</dependency>
The above example goes in your pom.xml file under <dependencies>
. The scope
is the magic here.
But if you want to run OmegaT with your plugin under development, then you'd have to temporary remove <scope>provided</scope>
.
To produce a .jar
file, you can use the maven-jar-plugin
as seen below.
If you used stubs or copied OmegaT .java
files to your project, you can exclude them from the .jar
file using the
<excludes>
section.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<addClasspath>true</addClasspath>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<!-- gives Implementation-Title: $project.name
Implementation-Version: $project.version
[Implementation-Vendor: $project.organization.name]
-->
</manifest>
<manifestEntries>
<OmegaT-Plugins>org.myorganization.MyFilter</OmegaT-Plugins>
<Plugin-Description>I describe my plugin here. This plugin does amazing things</Plugin-Description>
<Plugin-Author>Your name here.</Plugin-Author>
<Plugin-Category>filter</Plugin-Category>
<Plugin-Version>1.0.0</Plugin-Version>
<Plugin-Link>https://example.com/project/home/page</Plugin-Link>
<Plugin-License>SPDX identifier such as GPL-3</Plugin-License>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<excludes>
<exclude>org.omegat/**</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>