Made progress on alternate packaging of PackPartitions as a plugin for Outlaw.

This commit is contained in:
Martin Haye 2016-07-12 17:01:36 -07:00
parent 7c297f757d
commit b5cf46d503
8 changed files with 183 additions and 119 deletions

4
.gitignore vendored
View File

@ -31,6 +31,7 @@ mg
/Platform/Apple/virtual/src/include/build.props
/Platform/Apple/tools/A2Copy/build/
/Platform/Apple/tools/PackPartitions/build/
/Platform/Apple/tools/A2PackPlugin/dependency-reduced-pom.xml
# Ignore object and asm files produced by PLASMA
*.o
@ -47,4 +48,5 @@ mg
# Packer sometimes produces an error text file.
error_stack.txt
/OutlawEditor/OutlawPluginExample/target/
/Platform/Apple/tools/A2Pack/target/
/Platform/Apple/tools/A2Pack/target/
/Platform/Apple/tools/A2PackPlugin/target/

View File

@ -1,71 +0,0 @@
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.badvision</groupId>
<artifactId>A2Pack</artifactId>
<version>0.1</version>
<packaging>bundle</packaging>
<name>A2Pack</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.badvision.outlaw.plugin.a2pack</Export-Package>
<Bundle-Activator>org.badvision.outlaw.plugin.a2pack.Activator</Bundle-Activator>
<Export-Service>*</Export-Service>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.22.0</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
<goals>
<goal>scr</goal>
</goals>
<configuration>
<properties>
<service.vendor>8-Bit Bunch</service.vendor>
</properties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.badvision</groupId>
<artifactId>OutlawEditor</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
<version>5.4.0</version>
</dependency>
</dependencies>
</project>

View File

@ -1,41 +0,0 @@
package org.badvision.outlaw.plugin.a2pack;
import org.badvision.outlaweditor.api.ApplicationState;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
/**
* This is the activator for the A2Pack plugin, in charge of starting and stopping.
*
* @author mhaye
*/
public class Activator implements BundleActivator {
@Override
public void start(BundleContext bc) throws Exception {
System.out.println("Hello, Apple II packer!");
checkReferences();
}
@Override
public void stop(BundleContext bc) throws Exception {
System.out.println("Goodbye, Apple II packer!");
}
private void checkReferences() {
// Note that our activator is not a component, so we can't use the @Reference
// annotation to inject app automatically. ApplicationState has a convenience
// method to get around this in just such events, but it's a hack.
// Ultimately it's not a good idea to rely on this too much as it follows
// some bad practices behind the scene that leave unclosed references, etc.
// I'll have to come up with a safer way to inject dependencies without
// causing housekeeping issues for OSGi.
ApplicationState app = ApplicationState.getInstance();
if (app == null) {
System.out.println("App is null?!?!");
} else if (app.getCurrentPlatform() == null) {
System.out.println("Current platform is null?");
} else {
System.out.println("Current platform is " + app.getCurrentPlatform());
}
}
}

View File

@ -0,0 +1,134 @@
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.badvision</groupId>
<artifactId>A2PackPlugin</artifactId>
<version>0.1</version>
<packaging>bundle</packaging>
<name>A2PackPlugin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.badvision.outlaw.plugin.a2pack</Export-Package>
<Bundle-Activator>org.badvision.outlaw.plugin.a2pack.Activator</Bundle-Activator>
<Export-Service>*</Export-Service>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.22.0</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
<goals>
<goal>scr</goal>
</goals>
<configuration>
<properties>
<service.vendor>8-Bit Bunch</service.vendor>
</properties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.googlecode.addjars-maven-plugin</groupId>
<artifactId>addjars-maven-plugin</artifactId>
<version>1.0.5</version>
<executions>
<execution>
<goals>
<goal>add-jars</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${basedir}/../PackPartitions/dist</directory>
<includes>
<include>**/PackPartitions.jar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<artifactSet>
<excludes>
<exclude>org.badvision:OutlawEditor:jar:</exclude>
<exclude>org.jvnet.jaxb2_commons:jaxb2-basics:jar:</exclude>
<exclude>org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:</exclude>
<exclude>org.jvnet.jaxb2_commons:jaxb2-basics-tools:jar:</exclude>
<exclude>org.slf4j:slf4j-api:jar:</exclude>
<exclude>commons-beanutils:commons-beanutils:jar:</exclude>
<exclude>commons-collections:commons-collections:jar:</exclude>
<exclude>org.slf4j:jcl-over-slf4j:jar:</exclude>
<exclude>org.apache.commons:commons-lang3:jar:</exclude>
<exclude>com.google.code.javaparser:javaparser:jar:</exclude>
<exclude>org.apache.felix:org.apache.felix.framework:jar:</exclude>
<exclude>org.apache.felix:org.apache.felix.scr:jar:</exclude>
<exclude>org.codehaus.mojo:animal-sniffer-annotations:jar:</exclude>
<exclude>org.apache.poi:poi:jar:</exclude>
<exclude>commons-codec:commons-codec:jar:</exclude>
<exclude>org.apache.poi:poi-ooxml:jar:</exclude>
<exclude>org.apache.poi:poi-ooxml-schemas:jar:</exclude>
<exclude>org.apache.xmlbeans:xmlbeans:jar:</exclude>
<exclude>stax:stax-api:jar:</exclude>
<exclude>com.github.virtuald:curvesapi:jar:</exclude>
<exclude>org.apache.felix:org.apache.felix.scr.annotations:jar:</exclude>
<exclude>org.apache.felix:org.apache.felix.main:jar:</exclude>
</excludes>
</artifactSet>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.badvision</groupId>
<artifactId>OutlawEditor</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
<version>5.4.0</version>
</dependency>
</dependencies>
</project>

View File

@ -1,6 +1,9 @@
package org.badvision.outlaw.plugin.a2pack;
import java.io.File;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javax.xml.bind.JAXB;
import org.apache.felix.scr.annotations.Activate;
@ -30,7 +33,7 @@ public class A2PackPlugin implements MenuAction {
// This is called when our plugin is starting
@Activate
public void activate() throws Exception {
System.out.println("Hello, menu!");
System.out.println("Hello, menu 3!");
checkReferences();
}
@ -50,6 +53,17 @@ public class A2PackPlugin implements MenuAction {
@Override
public void handle(ActionEvent event)
{
System.out.println("Creating A2PackPartitions instance.");
try {
Class<?> clazz = Class.forName("org.badvision.A2PackPartitions");
Method m = clazz.getMethod("hello", String[].class);
String[] params = null;
m.invoke(null, (Object) params);
} catch (Exception ex) {
System.out.println("...failed: " + ex.toString());
throw new RuntimeException(ex);
}
System.out.println("...created.");
File currentSaveFile = UIAction.getCurrentSaveFile();
if (currentSaveFile == null || !currentSaveFile.exists()) {
UIAction.alert("You must open a world file\nbefore building a disk.");

View File

@ -0,0 +1,21 @@
package org.badvision.outlaw.plugin.a2pack;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
/**
* This is the activator for the A2Pack plugin, in charge of starting and stopping.
*
* @author mhaye
*/
public class Activator implements BundleActivator {
@Override
public void start(BundleContext bc) throws Exception {
System.out.println("Hello, Apple II packer!");
}
@Override
public void stop(BundleContext bc) throws Exception {
System.out.println("Goodbye, Apple II packer!");
}
}

View File

@ -19,7 +19,7 @@
<zipfileset src="./lib/groovy-all-2.4.6.jar"/>
<zipfileset src="dist/${application.title}-thin.jar" />
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Main-Class" value="org.badvision.A2PackPartitions"/>
</manifest>
<fileset dir="../..">
<include name="virtual/src/**/*.pla"/>

View File

@ -13,7 +13,7 @@
* Apple II version of MythOS.
*/
package org.demo
package org.badvision
import java.nio.ByteBuffer
import java.nio.channels.Channels
@ -28,7 +28,7 @@ import javax.xml.bind.DatatypeConverter
*
* @author mhaye
*/
class PackPartitions
class A2PackPartitions
{
def TRANSPARENT_COLOR = 15
@ -2485,6 +2485,11 @@ end
new a2copy.A2Copy().main(args)
}
static void hello(String[] args)
{
System.out.println("Hello from pack partitions (groovy).")
}
static void main(String[] args)
{
// Set auto-flushing for stdout
@ -2542,12 +2547,12 @@ end
def inst
try {
// Create PLASMA headers
inst = new PackPartitions()
inst = new A2PackPartitions()
inst.buildDir = buildDir
inst.dataGen(xmlFile)
// Pack everything into a binary file
inst = new PackPartitions() // make a new one without stubs
inst = new A2PackPartitions() // make a new one without stubs
inst.buildDir = buildDir
inst.pack(xmlFile)