Skip to content

Commit 7d18ab2

Browse files
committed
Added the initial code from the ComiXed project [#1]
* Added building the release bundle.
1 parent 04b79b1 commit 7d18ab2

9 files changed

Lines changed: 417 additions & 2 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Compiled class file
22
*.class
33

4+
# Build and IDE directories
5+
target
6+
.idea
7+
CHANGELOG.md
8+
49
# Log file
510
*.log
611

.mvn/jvm.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
2+
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
3+
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
4+
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
5+
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
6+
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

CONTRIBUTORS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Project Contributors
2+
3+
The following people have provided their time and efforts to help make the ComiXed Python plugin what it is today.
4+
5+
* Darryl L. Pierce <mcpierce@gmail.com>

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
# comixed-plugin-language-groovy
2-
The Groovy plugin language runtime for ComiXed
1+
# ComiXed Plugin Language Python
2+
3+
This project provides a language runtime for ComiXed that executes plugins
4+
written in [Groovy](https://groovy-lang.org/).
5+
6+
It does **not** provide the full Groovy language's runtime libraries. Instead,
7+
it only provides the core **language** interpreter to execute plugins.
8+
9+
# Status
10+
11+
[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=comixed_comixed-plugin-language-groovy)](https://sonarcloud.io/dashboard?id=comixed_comixed-plugin-language-groovy)\
12+
[![Github All Releases](https://img.shields.io/github/downloads/comixed/comixed-plugin-language-groovy/total.svg)](https://github.com/comixed/comixed-plugin-language-groovy/releases)
13+
14+
# Installation And Configuration
15+
16+
See the [installation](INSTALLATION.md) file for details.

pom.xml

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.comixedproject</groupId>
5+
<artifactId>comixed-plugin-language-groovy</artifactId>
6+
<packaging>jar</packaging>
7+
<version>0.1-SNAPSHOT</version>
8+
<name>comixed-plugin-language-groovy</name>
9+
<url>https://github.com/comixed/comixed-plugin-language-groovy</url>
10+
11+
<scm>
12+
<connection>scm:git:git@github.com:comixed/comixed-plugin-language-groovy.git</connection>
13+
<developerConnection>scm:git:git@github.com:comixed/comixed-plugin-language-groovy.git</developerConnection>
14+
<url>scm:git:git@github.com:comixed/comixed-plugin-language-groovy.git</url>
15+
<tag>main</tag>
16+
</scm>
17+
18+
<issueManagement>
19+
<system>GitHub</system>
20+
<url>https://github.com/comixed/comixed-plugin-language-groovy/issues</url>
21+
</issueManagement>
22+
23+
<properties>
24+
<java.version>21</java.version>
25+
<assembly.name>local</assembly.name>
26+
<maven-git-code-format.version>5.1</maven-git-code-format.version>
27+
<sonar.organization>comixed</sonar.organization>
28+
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
29+
<sonar.links.scm>https://github.com/comixed/comixed-plugin-language-groovy</sonar.links.scm>
30+
<sonar.links.issue>https://github.com/comixed/comixed-plugin-language-groovy/issues</sonar.links.issue>
31+
<sonar.sources>${project.basedir}/src/main/java</sonar.sources>
32+
<lombok.version>1.18.30</lombok.version>
33+
<log4j.version>2.20.0</log4j.version>
34+
</properties>
35+
36+
<dependencies>
37+
<dependency>
38+
<groupId>org.apache.groovy</groupId>
39+
<artifactId>groovy-all</artifactId>
40+
<version>5.0.0</version>
41+
<type>pom</type>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.comixedproject</groupId>
45+
<artifactId>comixed-plugins</artifactId>
46+
<version>3.0.3</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.projectlombok</groupId>
50+
<artifactId>lombok</artifactId>
51+
<version>${lombok.version}</version>
52+
<scope>compile</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.apache.logging.log4j</groupId>
56+
<artifactId>log4j-api</artifactId>
57+
<version>${log4j.version}</version>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.apache.logging.log4j</groupId>
61+
<artifactId>log4j-core</artifactId>
62+
<version>${log4j.version}</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>junit</groupId>
66+
<artifactId>junit</artifactId>
67+
<version>4.13.2</version>
68+
<scope>test</scope>
69+
</dependency>
70+
<dependency>
71+
<groupId>org.mockito</groupId>
72+
<artifactId>mockito-core</artifactId>
73+
<version>4.0.0</version>
74+
<scope>test</scope>
75+
</dependency>
76+
</dependencies>
77+
78+
<build>
79+
<plugins>
80+
<plugin>
81+
<groupId>org.apache.maven.plugins</groupId>
82+
<artifactId>maven-compiler-plugin</artifactId>
83+
<version>3.8.1</version>
84+
<configuration>
85+
<source>${java.version}</source>
86+
<target>${java.version}</target>
87+
<annotationProcessorPaths>
88+
<path>
89+
<groupId>org.projectlombok</groupId>
90+
<artifactId>lombok</artifactId>
91+
<version>${lombok.version}</version>
92+
</path>
93+
</annotationProcessorPaths>
94+
</configuration>
95+
</plugin>
96+
<plugin>
97+
<groupId>com.cosium.code</groupId>
98+
<artifactId>git-code-format-maven-plugin</artifactId>
99+
<version>${maven-git-code-format.version}</version>
100+
<executions>
101+
<execution>
102+
<id>install-formatter-hook</id>
103+
<goals>
104+
<goal>install-hooks</goal>
105+
</goals>
106+
</execution>
107+
<execution>
108+
<id>validate-code-format</id>
109+
<goals>
110+
<goal>validate-code-format</goal>
111+
</goals>
112+
</execution>
113+
</executions>
114+
<dependencies>
115+
<dependency>
116+
<groupId>com.cosium.code</groupId>
117+
<artifactId>google-java-format</artifactId>
118+
<version>4.2</version>
119+
</dependency>
120+
</dependencies>
121+
</plugin>
122+
<plugin>
123+
<artifactId>maven-clean-plugin</artifactId>
124+
<version>3.1.0</version>
125+
<configuration>
126+
<filesets>
127+
<fileset>
128+
<directory>${project.basedir}</directory>
129+
<includes>CHANGELOG.md</includes>
130+
<includes>comixed-metadata-comicvine-*.zip</includes>
131+
</fileset>
132+
</filesets>
133+
</configuration>
134+
</plugin>
135+
<plugin>
136+
<artifactId>maven-clean-plugin</artifactId>
137+
<version>3.1.0</version>
138+
<configuration>
139+
<filesets>
140+
<fileset>
141+
<directory>${project.basedir}</directory>
142+
<includes>CHANGELOG.md</includes>
143+
<includes>comixed-plugin-language-groovy-*.zip</includes>
144+
</fileset>
145+
</filesets>
146+
</configuration>
147+
</plugin>
148+
<plugin>
149+
<groupId>com.github.danielflower.mavenplugins</groupId>
150+
<artifactId>gitlog-maven-plugin</artifactId>
151+
<version>1.14.0</version>
152+
<configuration>
153+
<reportTitle>Changelog for the ComiXed Groovy Language Plugin v0.1-SNAPSHOT</reportTitle>
154+
<verbose>false</verbose>
155+
<outputDirectory>${project.basedir}</outputDirectory>
156+
<generateMarkdownChangeLog>true</generateMarkdownChangeLog>
157+
<markdownChangeLogFilename>CHANGELOG.md</markdownChangeLogFilename>
158+
<generateSimpleHTMLChangeLog>false</generateSimpleHTMLChangeLog>
159+
<generatePlainTextChangeLog>false</generatePlainTextChangeLog>
160+
<generateAsciidocChangeLog>false</generateAsciidocChangeLog>
161+
<generateJSONChangeLog>false</generateJSONChangeLog>
162+
<generateHTMLTableOnlyChangeLog>false</generateHTMLTableOnlyChangeLog>
163+
<issueManagementSystem>GitHub issue tracker</issueManagementSystem>
164+
<issueManagementUrl>https://github.com/comixed/comixed/issues</issueManagementUrl>
165+
<fullGitMessage>false</fullGitMessage>
166+
<dateFormat>yyyy-MM-dd HH:mm:ss Z</dateFormat>
167+
<bugzillaPattern>(?:Bug|UPDATE|FIX|ADD|NEW|#) ?#?(\d+)</bugzillaPattern>
168+
</configuration>
169+
<executions>
170+
<execution>
171+
<goals>
172+
<goal>generate</goal>
173+
</goals>
174+
</execution>
175+
</executions>
176+
</plugin>
177+
<plugin>
178+
<groupId>org.sonarsource.scanner.maven</groupId>
179+
<artifactId>sonar-maven-plugin</artifactId>
180+
<version>4.0.0.4121</version>
181+
</plugin>
182+
<plugin>
183+
<artifactId>maven-assembly-plugin</artifactId>
184+
<version>3.2.0</version>
185+
<configuration>
186+
<outputDirectory>${project.basedir}</outputDirectory>
187+
<descriptors>
188+
<descriptor>src/main/assembly/src.xml</descriptor>
189+
</descriptors>
190+
</configuration>
191+
<executions>
192+
<execution>
193+
<id>make-assembly</id>
194+
<phase>package</phase>
195+
<goals>
196+
<goal>single</goal>
197+
</goals>
198+
</execution>
199+
</executions>
200+
</plugin>
201+
</plugins>
202+
</build>
203+
</project>

src/main/assembly/src.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
4+
<id>${assembly.name}</id>
5+
<formats>
6+
<format>zip</format>
7+
</formats>
8+
<dependencySets>
9+
<dependencySet>
10+
<unpack>false</unpack>
11+
<includes>
12+
<include>org.comixedproject:comixed-plugin-language-groovy:jar:</include>
13+
<include>org.apache.groovy:groovy:jar:</include>
14+
</includes>
15+
</dependencySet>
16+
</dependencySets>
17+
<fileSets>
18+
<fileSet>
19+
<directory>${project.basedir}</directory>
20+
<includes>
21+
<include>CHANGELOG.md</include>
22+
<include>CONTRIBUTORS.md</include>
23+
<include>INSTALLATION.md</include>
24+
<include>LICENSE</include>
25+
<include>README.md</include>
26+
<include>CHANGELOG.md</include>
27+
</includes>
28+
</fileSet>
29+
</fileSets>
30+
</assembly>
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* ComiXed - A digital comic book library management application.
3+
* Copyright (C) 2023, The ComiXed Project
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses>
17+
*/
18+
19+
package org.comixedproject.plugins.groovy;
20+
21+
import groovy.lang.Binding;
22+
import groovy.lang.GroovyShell;
23+
import groovy.lang.Script;
24+
import java.io.File;
25+
import java.util.ArrayList;
26+
import java.util.List;
27+
import lombok.extern.log4j.Log4j2;
28+
import org.comixedproject.model.plugin.LibraryPlugin;
29+
import org.comixedproject.model.plugin.LibraryPluginProperty;
30+
import org.comixedproject.plugins.AbstractPluginRuntime;
31+
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
32+
import org.springframework.context.annotation.Scope;
33+
import org.springframework.stereotype.Component;
34+
35+
/**
36+
* <code>GroovyPluginRuntime</code> provides a runtime environment that loads and executes a Groovy
37+
* plugin.
38+
*
39+
* @author Darryl L. Pierce
40+
*/
41+
@Component
42+
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
43+
@Log4j2
44+
public class GroovyPluginRuntime extends AbstractPluginRuntime {
45+
@Override
46+
public String getName(final String filename) {
47+
final GroovyShell shell = doCreatePluginShell();
48+
try {
49+
log.trace("Loading plugin properties: {}", filename);
50+
final Script script = shell.parse(new File(filename));
51+
return (String) script.invokeMethod("plugin_name", new Object[] {});
52+
} catch (Exception error) {
53+
log.error("Failed to load plugin properties", error);
54+
return "";
55+
}
56+
}
57+
58+
@Override
59+
public String getVersion(final String filename) {
60+
final GroovyShell shell = doCreatePluginShell();
61+
try {
62+
log.trace("Loading plugin properties: {}", filename);
63+
final Script script = shell.parse(new File(filename));
64+
return (String) script.invokeMethod("plugin_version", new Object[] {});
65+
} catch (Exception error) {
66+
log.error("Failed to load plugin properties", error);
67+
return "";
68+
}
69+
}
70+
71+
@Override
72+
public List<LibraryPluginProperty> getProperties(final String filename) {
73+
final GroovyShell shell = doCreatePluginShell();
74+
try {
75+
log.trace("Loading plugin properties: {}", filename);
76+
final Script script = shell.parse(new File(filename));
77+
return (List<LibraryPluginProperty>)
78+
script.invokeMethod("plugin_properties", new Object[] {});
79+
} catch (Exception error) {
80+
log.error("Failed to load plugin properties", error);
81+
return new ArrayList<>();
82+
}
83+
}
84+
85+
@Override
86+
public Boolean execute(final LibraryPlugin libraryPlugin) {
87+
final var shell = doCreatePluginShell();
88+
try {
89+
log.trace(
90+
"Executing libraryPlugin: {} v{}", libraryPlugin.getName(), libraryPlugin.getVersion());
91+
this.getProperties()
92+
.entrySet()
93+
.forEach(entry -> shell.setProperty(entry.getKey(), entry.getValue()));
94+
shell.evaluate(new File(libraryPlugin.getFilename()));
95+
log.trace("LibraryPlugin completed without error");
96+
return true;
97+
} catch (Exception error) {
98+
log.error("Failed to execute libraryPlugin", error);
99+
return false;
100+
}
101+
}
102+
103+
private GroovyShell doCreatePluginShell() {
104+
log.trace("Creating plugin binding");
105+
final Binding binding = new Binding();
106+
log.trace("Creating plugin runtime shell");
107+
return new GroovyShell(binding);
108+
}
109+
}

0 commit comments

Comments
 (0)