Skip to content

Commit

Permalink
[JBPM-9156] WorkItemHandler archetype can't be uploaded into business…
Browse files Browse the repository at this point in the history
…-central (#1652)
  • Loading branch information
bxf12315 committed Jun 9, 2020
1 parent 74b525d commit fa593e7
Show file tree
Hide file tree
Showing 16 changed files with 827 additions and 82 deletions.
Expand Up @@ -4,18 +4,19 @@
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jbpm.contrib</groupId>
<artifactId>workitems</artifactId>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-workitems-repository-bom-parent</artifactId>
<version>${archetypeVersion}</version>
</parent>

<artifactId>${rootArtifactId}</artifactId>
<name>${rootArtifactId}</name>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<name>${artifactId}</name>
<version>${version}</version>
<description>Workitem Desciption</description>
<organization>
<name>organization</name>
</organization>

<dependencies>
<dependency>
<groupId>org.kie</groupId>
Expand Down Expand Up @@ -66,58 +67,25 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<groupId>org.jbpm.contrib</groupId>
<artifactId>template-resources</artifactId>
<scope>provided</scope>
<version>${version.org.kie}</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.build.directory}/generated-sources/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>*.png</include>
</includes>
</resource>
<resource>
<directory>${project.build.directory}/maven-shared-archive-resources</directory>
<filtering>true</filtering>
<includes>
<include>*.part</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>filter-src</id>
<goals>
<goal>filter-sources</goal>
</goals>
<configuration>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>1.5</version>
<configuration>
<resourceBundles>
<resourceBundle>${project.groupId}:template-resources:${project.version}</resourceBundle>
<resourceBundle>org.jbpm.contrib:template-resources:${version.org.kie}</resourceBundle>
</resourceBundles>
</configuration>
<executions>
Expand All @@ -128,34 +96,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-repository-resources</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<resources>
<resource>
<directory>target/generated-sources/annotations</directory>
<includes>
<include>repoindex.html</include>
<include>*.wid</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<outputDirectory>target/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
</project>
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
* Copyright 2020 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,7 +43,7 @@
@WidResult(name="SampleResult")
},
mavenDepends={
@WidMavenDepends(group="${groupId}", artifact="${artifactId}", version="${archetypeVersion}")
@WidMavenDepends(group="${groupId}", artifact="${artifactId}", version="${version}")
},
serviceInfo = @WidService(category = "${artifactId}", description = "${description}",
keywords = "",
Expand All @@ -54,16 +54,21 @@
)
)
public class ${classPrefix}WorkItemHandler extends AbstractLogOrThrowWorkItemHandler {
private String sampleParam;
private String sampleParamTwo;

public void executeWorkItem(WorkItem workItem,
WorkItemManager manager) {
public ${classPrefix}WorkItemHandler(String SampleParam, String SampleParamTwo){
this.sampleParam = sampleParam;
this.sampleParamTwo = sampleParamTwo;
}

public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
try {
RequiredParameterValidator.validate(this.getClass(),
workItem);
RequiredParameterValidator.validate(this.getClass(), workItem);

// sample parameters
String sampleParam = (String) workItem.getParameter("SampleParam");
String sampleParamTwo = (String) workItem.getParameter("SampleParamTwo");
sampleParam = (String) workItem.getParameter("SampleParam");
sampleParamTwo = (String) workItem.getParameter("SampleParamTwo");

// complete workitem impl...

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
* Copyright 2020 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,7 @@ public void testHandler() throws Exception {

TestWorkItemManager manager = new TestWorkItemManager();

${classPrefix}WorkItemHandler handler = new ${classPrefix}WorkItemHandler();
${classPrefix}WorkItemHandler handler = new ${classPrefix}WorkItemHandler("testParamValue", "testParamValue");
handler.setLogThrownException(true);
handler.executeWorkItem(workItem,
manager);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
* Copyright 2020 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
42 changes: 42 additions & 0 deletions jbpm-workitems/jbpm-workitems-repository-archetype/README.md
@@ -0,0 +1,42 @@
# WorkItem Archetype

Archetype used to build new jBPM Workitems.

This Archetype allows you to easily start building a new jBPM Workitem and easily be contributed to the workitem repository.
It creates your WorkItem Handler Maven project that includes the base Handler class, test, and
a zip file that includes all needed files to upload to a jBPM workitem repository.

How to run it
--------------------
1. build the jbpm-workitems module (mvn clean install)
2. Change to directory of your choice where you want to build the
base workitem handler from this archetype.
3. Create your new workitem handler from the archetype with:
```
mvn archetype:generate
-DarchetypeGroupId=org.jbpm
-DarchetypeArtifactId=jbpm-workitems-repository-archetype
-DarchetypeVersion=7.38.0-SNAPSHOT
-Dversion=7.38.0-SNAPSHOT
-DgroupId=org.jbpm.contrib
-DartifactId=myworkitem
-DclassPrefix=MyWorkItem
-DarchetypeCatalog=local
```
or use this one-liner

```
mvn archetype:generate -DarchetypeGroupId=org.jbpm -DarchetypeArtifactId=jbpm-workitems-repository-archetype -DarchetypeVersion=7.38.0-SNAPSHOT -Dversion=7.38.0-SNAPSHOT -DgroupId=org.jbpm.contrib -DartifactId=myworkitem -DclassPrefix=MyWorkItem -DarchetypeCatalog=local
```
4. Change the prompted values during the generation as needed (or leave the defaults)
5. Compile and test your generated workitem handler with
```
mvn clean install
```
6. Package your workitem with
```
mvn package
```
This will create a zip file in your projects /target directory. This zip when extracted includes the correct
directory structure (including the index.conf file) which then you can easily upload to a jBPM workitem repository
or use directly as-is to upload your new workitem to the workbench via the jBPM Designer workitem repository feature.
36 changes: 36 additions & 0 deletions jbpm-workitems/jbpm-workitems-repository-archetype/pom.xml
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jbpm-workitems</artifactId>
<groupId>org.jbpm</groupId>
<version>7.39.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<groupId>org.jbpm</groupId>
<artifactId>jbpm-workitems-repository-archetype</artifactId>
<name>Archetype</name>
<packaging>maven-archetype</packaging>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>3.0.1</version>
</extension>
</extensions>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>3.0.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor name="${artifactId}">

<requiredProperties>
<requiredProperty key="classPrefix"/>
<requiredProperty key="archetypeVersion"/>
</requiredProperties>

<fileSets>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
<fileSet filtered="false" packaged="false" encoding="UTF-8">
<directory>src/main/resources</directory>
<includes>
<include>**/*.st</include>
<include>**/*.png</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/repository</directory>
<includes>
<include>**/*.conf</include>
<include>**/*.wid</include>
<include>**/*.png</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory>assembly</directory>
<includes>
<include>**/*.xml</include>
</includes>
</fileSet>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
<directory>src/test/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
<directory>src/test/resources</directory>
</fileSet>
</fileSets>

</archetype-descriptor>
@@ -0,0 +1,12 @@
/target
/local
/bin

# Eclipse, Netbeans and IntelliJ files
/.*
!.gitignore
/nbproject
/*.ipr
/*.iws
/*.iml

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>bin</id>
<formats>
<format>dir</format>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>

<fileSets>
<fileSet>
<directory>target</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>target/generated-sources/annotations</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.wid</include>
<include>index.html</include>
<include>*.json</include>
<include>*.xml</include>
<include>*.bpmn2</include>
</includes>
</fileSet>
<fileSet>
<directory>target/classes</directory>
<outputDirectory></outputDirectory>
<includes>
<include>repoconf.part</include>
<include>repoindex.html</include>
<include>*.png</include>
<include>*.bpmn2</include>
</includes>
</fileSet>
</fileSets>
</assembly>

0 comments on commit fa593e7

Please sign in to comment.