Skip to content

Commit 637f7e8

Browse files
committed
a PetriSpot wrapper
1 parent ce48f70 commit 637f7e8

7 files changed

Lines changed: 231 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"/>
4+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5+
<classpathentry kind="src" path="src/"/>
6+
<classpathentry kind="output" path="target/classes"/>
7+
</classpath>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target/
2+
/bin/
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>fr.lip6.petrispot.binaries</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.pde.ManifestBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.SchemaBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.maven.ide.eclipse.maven2Builder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
<buildCommand>
29+
<name>org.eclipse.m2e.core.maven2Builder</name>
30+
<arguments>
31+
</arguments>
32+
</buildCommand>
33+
</buildSpec>
34+
<natures>
35+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
36+
<nature>org.maven.ide.eclipse.maven2Nature</nature>
37+
<nature>org.eclipse.pde.PluginNature</nature>
38+
<nature>org.eclipse.jdt.core.javanature</nature>
39+
</natures>
40+
</projectDescription>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Manifest-Version: 1.0
2+
Bundle-ManifestVersion: 2
3+
Bundle-Name: PetriSpot packaging for binary tools
4+
Bundle-SymbolicName: fr.lip6.petrispot.binaries;singleton:=true
5+
Bundle-Version: 1.0.0.qualifier
6+
Bundle-Activator: fr.lip6.petrispot.binaries.BinaryToolsPlugin
7+
Eclipse-BundleShape: dir
8+
Require-Bundle: org.eclipse.core.runtime
9+
Bundle-ActivationPolicy: lazy
10+
Bundle-RequiredExecutionEnvironment: JavaSE-21
11+
Bundle-ClassPath: .
12+
Bundle-Vendor: LIP6
13+
Export-Package: fr.lip6.petrispot.binaries
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source.. = src/
2+
output.. = bin/
3+
bin.includes = META-INF/,\
4+
.,\
5+
bin/
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<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/maven-v4_0_0.xsd">
2+
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>fr.lip6.move.gal</groupId>
7+
<artifactId>fr.lip6.move.gal.parent</artifactId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
<relativePath>../../fr.lip6.move.gal.parent/pom.xml</relativePath>
10+
</parent>
11+
12+
<artifactId>fr.lip6.petrispot.binaries</artifactId>
13+
<packaging>eclipse-plugin</packaging>
14+
<name>PetriSpot binaries</name>
15+
<description>PetriSpot binary packaging (Petri net invariants solver).</description>
16+
17+
<build>
18+
<plugins>
19+
<!-- Fetch the binaries from GitHub releases -->
20+
<plugin>
21+
<groupId>org.apache.maven.plugins</groupId>
22+
<artifactId>maven-antrun-plugin</artifactId>
23+
<executions>
24+
<execution>
25+
<id>compile</id>
26+
<phase>compile</phase>
27+
<configuration>
28+
<target>
29+
<echo message="Get PetriSpot binaries"/>
30+
<mkdir dir="bin"/>
31+
<get src="https://github.com/yanntm/PetriSpot/raw/refs/heads/Inv-Linux/petri64" dest="bin/petri64"/>
32+
<get src="https://github.com/yanntm/PetriSpot/raw/refs/heads/Inv-Windows/petri64.exe" dest="bin/petri64.exe"/>
33+
<chmod dir="bin/" type="file" perm="a+rx" includes="**/*"/>
34+
</target>
35+
</configuration>
36+
<goals>
37+
<goal>run</goal>
38+
</goals>
39+
</execution>
40+
</executions>
41+
</plugin>
42+
</plugins>
43+
</build>
44+
45+
</project>
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/**
2+
* Copyright (c) 2006-2010 MoVe - Laboratoire d'Informatique de Paris 6 (LIP6).
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Jean-Baptiste VORON (LIP6) - Project Head / Initial contributor
10+
* Clément DÉMOULINS (LIP6) - Project Manager
11+
* Yann THIERRY-MIEG (LIP6)
12+
*
13+
* Official contacts:
14+
* coloane@lip6.fr
15+
* http://coloane.lip6.fr
16+
*/
17+
package fr.lip6.petrispot.binaries;
18+
19+
import java.io.File;
20+
import java.io.IOException;
21+
import java.net.URI;
22+
import java.net.URISyntaxException;
23+
import java.net.URL;
24+
import java.util.Enumeration;
25+
import java.util.logging.Logger;
26+
27+
import org.eclipse.core.runtime.FileLocator;
28+
import org.eclipse.core.runtime.Plugin;
29+
import org.osgi.framework.BundleContext;
30+
31+
/**
32+
* The activator class controls the plug-in life cycle
33+
*/
34+
public class BinaryToolsPlugin extends Plugin {
35+
36+
// The plug-in ID
37+
public static final String PLUGIN_ID = "fr.lip6.petrispot.binaries"; //$NON-NLS-1$
38+
39+
// The shared instance
40+
private static BinaryToolsPlugin plugin;
41+
42+
private static URI petriUri = null;
43+
44+
/**
45+
* The constructor
46+
*/
47+
public BinaryToolsPlugin() {
48+
}
49+
50+
/** {@inheritDoc} */
51+
public final void start(BundleContext context) throws Exception {
52+
super.start(context);
53+
plugin = this;
54+
}
55+
56+
/** {@inheritDoc} */
57+
public final void stop(BundleContext context) throws Exception {
58+
plugin = null;
59+
super.stop(context);
60+
}
61+
62+
/**
63+
* Returns the shared instance
64+
*
65+
* @return the shared instance
66+
*/
67+
public static BinaryToolsPlugin getDefault() {
68+
return plugin;
69+
}
70+
71+
private static final Logger log = Logger.getLogger("fr.lip6.move.gal"); //$NON-NLS-1$
72+
73+
/**
74+
* Returns the URI of the petri64 binary for the current platform.
75+
*/
76+
public static URI getPetriURI() throws IOException {
77+
if (petriUri == null) {
78+
String relativePath = "bin/" + getPetriExecutableName();
79+
URL resource = getDefault().getBundle().getResource(relativePath);
80+
if (resource == null) {
81+
log.severe("unable to find PetriSpot binary in path " + relativePath);
82+
Enumeration<URL> e = getDefault().getBundle().findEntries("bin/", "*", true);
83+
log.fine("Listing URLs available in bin/");
84+
while (e.hasMoreElements()) {
85+
log.finer(e.nextElement().toString());
86+
}
87+
throw new IOException("unable to find the PetriSpot binary");
88+
}
89+
URL fileUrl = FileLocator.toFileURL(resource);
90+
try {
91+
petriUri = new URI(fileUrl.getProtocol(), fileUrl.getPath(), null);
92+
} catch (URISyntaxException e) {
93+
throw new IOException("Could not create a URI to access the PetriSpot binary:", e);
94+
}
95+
log.fine("Location of PetriSpot binary: " + petriUri);
96+
97+
File executable = new File(petriUri);
98+
if (!executable.setExecutable(true)) {
99+
log.severe("unable to make PetriSpot executable [" + petriUri + "]");
100+
throw new IOException("unable to make PetriSpot executable");
101+
}
102+
}
103+
return petriUri;
104+
}
105+
106+
/**
107+
* Returns the platform-specific executable name for PetriSpot.
108+
*/
109+
private static String getPetriExecutableName() throws IOException {
110+
String osName = System.getProperty("os.name").toLowerCase();
111+
if (osName.contains("windows")) {
112+
return "petri64.exe";
113+
} else if (osName.contains("linux")) {
114+
return "petri64";
115+
} else {
116+
throw new IOException("System platform not supported by PetriSpot: " + osName);
117+
}
118+
}
119+
}

0 commit comments

Comments
 (0)