Skip to content

Commit

Permalink
touchup of poms
Browse files Browse the repository at this point in the history
  • Loading branch information
msx80 committed Apr 28, 2024
1 parent eb9044a commit 9c017fb
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 91 deletions.
33 changes: 21 additions & 12 deletions demo/FeatureDemo/pom.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>

<artifactId>feature-demo</artifactId>
<groupId>com.github.msx80.omicron</groupId>
<version>0.0.3</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.github.msx80</groupId>
Expand All @@ -29,18 +42,11 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<!-- generate fat jar with the dependencies -->
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
Expand All @@ -58,6 +64,7 @@
</executions>
</plugin>
<plugin>
<!-- rename the generated jar to an omicron cartridge -->
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
Expand All @@ -69,13 +76,15 @@
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar</sourceFile>
<sourceFile>
${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar</sourceFile>
<destinationFile>${project.artifactId}.omicron</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- make the game executable with exec:exec -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
Expand All @@ -84,7 +93,7 @@
<classpathScope>test</classpathScope>
<arguments>
<argument>-classpath</argument>
<classpath/>
<classpath />
<argument>com.github.msx80.omicron.DesktopLauncher</argument>
<argument>omicron.demo.featuresdemo.FeaturesDemo</argument>
</arguments>
Expand Down
148 changes: 77 additions & 71 deletions demo/FeatureDemoStandalone/pom.xml
Original file line number Diff line number Diff line change
@@ -1,85 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>

<artifactId>feature-demo</artifactId>
<groupId>com.github.msx80.omicron</groupId>
<version>0.0.3</version>
<artifactId>feature-demo</artifactId>
<groupId>com.github.msx80.omicron</groupId>
<version>0.0.3</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<repositories>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>

<dependency>
<groupId>com.github.msx80.omicron</groupId>
<version>0.0.3</version>
<artifactId>omicron-desktop</artifactId>
</dependency>

</dependencies>
<build>
<plugins>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>omicron.demo.featuresdemo.FeaturesDemo</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>rename-file</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar</sourceFile>
<destinationFile>${project.artifactId}-standalone.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>

<configuration>
<mainClass>omicron.demo.featuresdemo.FeaturesDemo</mainClass>
</configuration>
</plugin>
</plugins>
<dependencies>
<dependency>
<groupId>com.github.msx80.omicron</groupId>
<version>0.0.3</version>
<artifactId>omicron-desktop</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<!-- generate fat jar with the engine and all -->
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>omicron.demo.featuresdemo.FeaturesDemo</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- copy the jar with a different name, not sure about this -->
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>rename-file</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>
${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar</sourceFile>
<destinationFile>
${project.artifactId}-standalone.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- make this executable with exec:exec -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<mainClass>omicron.demo.featuresdemo.FeaturesDemo</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import com.github.msx80.omicron.basicutils.Colors;
import com.github.msx80.omicron.basicutils.MapDrawer;
import com.github.msx80.omicron.basicutils.text.TextDrawerFixed;

import com.github.msx80.omicron.DesktopLauncher;
import com.github.msx80.omicron.api.Controller;
import com.github.msx80.omicron.api.Game;
import com.github.msx80.omicron.api.Pointer;
import com.github.msx80.omicron.api.Sys;
import com.github.msx80.omicron.api.SysConfig;
import com.github.msx80.omicron.api.SysConfig.VirtualScreenMode;

import com.github.msx80.omicron.fantasyconsole.cartridges.ClassCartridge;
import com.github.msx80.omicron.fantasyconsole.cartridges.ClasspathCartridge;

public class FeaturesDemo implements Game {
Expand Down Expand Up @@ -161,7 +161,7 @@ public SysConfig sysConfig() {
}

public static void main(String[] args) {
com.github.msx80.omicron.DesktopLauncher.launch(new ClasspathCartridge("FeaturesDemo", "omicron.demo.featuresdemo", "FeaturesDemo"), false, args);
DesktopLauncher.launch(new ClassCartridge("FeaturesDemo", omicron.demo.featuresdemo.FeaturesDemo.class), false, args);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.github.msx80.omicron.fantasyconsole.cartridges;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.Properties;

import com.github.msx80.omicron.api.Game;
import com.github.msx80.omicron.api.adv.Cartridge;

import com.github.msx80.omicron.fantasyconsole.utils.FileUtil;

public class ClassCartridge implements Cartridge {


private Game game;
private Class<? extends Game> gameClass;

public ClassCartridge(String name, Class<? extends Game> gameClass)
{
this.gameClass = gameClass;
}

@Override
public Game getGameObject(){
try {
game = gameClass.getDeclaredConstructor().newInstance();
return game;
} catch (Exception e) {
throw new RuntimeException(e);
}
}

@Override
public byte[] loadFile(String name) {
try {
//String path = '/'+props.getProperty(PROP_PKG).replace('.', '/')+'/';
String path = '/'+gameClass.getPackage().getName().replace('.', '/')+'/';
InputStream is = game.getClass().getResourceAsStream(path+name);
if(is == null) return null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try
{
FileUtil.copy(is, baos);
}
finally
{
is.close();
}
return baos.toByteArray();
} catch (Exception e) {
throw new RuntimeException("Unable to load file from cartridge",e);
}
}

@Override
public Properties getOmicronProperties() {

return null;
}

@Override
public void close() {


}


}
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package com.github.msx80.omicron.fantasyconsole.cartridges;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.stream.Collectors;

import com.github.msx80.omicron.api.Game;
import com.github.msx80.wiseloader.BytesLoader;
import com.github.msx80.wiseloader.loaders.FileUtil;
import com.github.msx80.wiseloader.loaders.JarLoader;
import com.github.msx80.wiseloader.loaders.MultiBytesLoader;
import com.github.msx80.wiseloader.loaders.compiler.CompilingLoader;
Expand Down

0 comments on commit 9c017fb

Please sign in to comment.