* build.xml now generates more informative manifests

* Version class now extracts the version an build number from the manifest
* Some constants in Version class changed to getter method

git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk@184 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
angryziber 2007-07-25 22:21:51 +00:00
parent df4b46aee4
commit ae53418b03
9 changed files with 78 additions and 19 deletions

View File

@ -7,7 +7,7 @@
<property name="resources" value="resources"/>
<property name="testresults" value="testresults"/>
<property name="version" value="2.99a"/>
<property name="version" value="3.0-alpha1"/>
<property name="main.class" value="net.azib.ipscan.Main"/>
<property name="swt" value="ext/swt"/>
<property name="retroguard.jar" value="${ext}/retroguard/retroguard.jar"/>
@ -113,7 +113,14 @@
</emma>
</target>
<target name="package" depends="package-linux,package-win32,package-mac"/>
<target name="package" depends="svn-info,package-linux,package-win32,package-mac"/>
<target name="svn-info">
<!-- TODO: make this more cross-platform (most likely this will fail on windows) -->
<exec command="svn info --xml" output="svn-info.xml"/>
<xmlproperty file="svn-info.xml" prefix="svn"/>
<delete file="svn-info.xml"/>
</target>
<macrodef name="package-for">
<attribute name="platform"/>
@ -157,13 +164,14 @@
<include name="Table*"/>
<include name="Tree*"/>
</fileset>
<!-- About dialog doesn't work without these
<fileset dir="${bin}.@{platform}/org/eclipse/swt/accessibility"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/accessibility"/>-->
<fileset dir="${bin}.@{platform}/org/eclipse/swt/browser"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/ole"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/ole/win32" includes="I*"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/ole/win32" includes="O*"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/gdip"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/accessibility"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/opengl"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/opengl"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/cairo"/>
@ -198,7 +206,10 @@
<jar destfile="${dist}.@{platform}/${ant.project.name}-orig.jar" >
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="AngryIPScanner" value="${version}"/>
<attribute name="Title" value="Angry IP Scanner"/>
<attribute name="Version" value="${version}"/>
<attribute name="Build" value="${svn.info.entry(revision)}"/>
<attribute name="URL" value="http://www.azib.net/"/>
</manifest>
<fileset dir="${bin}" includes="**/*"/>
<fileset dir="${bin}.@{platform}" includes="**/*"/>

View File

@ -103,7 +103,7 @@ text.fetchers.selectedList=Selected fetchers
text.fetchers.availableList=Available fetchers
text.fetchers.info=Fetcher information:
text.fetchers.info.notAvailable=Unfortunately, no additional information about this fetcher is available.
text.about=%NAME\n\nVersion %VERSION\n%COPYLEFT\n\n<a>%WEBSITE</a>\n<a>%MAILTO</a>\n\nThis is an Open Source Software released under the GPL.
text.about=%NAME\n\nVersion %VERSION (build %BUILD)\n%COPYLEFT\n\n<a>%WEBSITE</a>\n<a>%MAILTO</a>\n\nThis is an Open Source Software released under the GPL.
text.gettingStarted=Dummy
text.gettingStarted1=Angry IP Scanner is an IP address scanner tool.\n\nIt is used for scanning IP addresses for finding alive hosts, gathering any kind of needed information about each host.
text.gettingStarted2=Main terminology:\n\nFeeder - generator of IP addresses for scanning. Angry IP Scanner provides various kinds of feeders: IP Range, Random, and IP List File. You can select a feeder using the combo box next to the "Start" button.\n\nFetcher - gathers specific information about a host, e.g. ping time, hostname, open ports. Feeders usually represent columns in the scanning results list.

View File

@ -3,6 +3,11 @@
*/
package net.azib.ipscan.config;
import java.net.URI;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.logging.Level;
/**
* Class with accessors to version information of the program.
*
@ -12,10 +17,6 @@ package net.azib.ipscan.config;
public class Version {
public static final String NAME = "Angry IP Scanner";
public static final String VERSION = "2.9-alpha";
public static final String FULL_NAME = NAME + " " + VERSION;
public static final String COPYLEFT = "\u00A9 2007 Anton Keks";
public static final String WEBSITE = "http://www.azib.net/ipscan/";
@ -26,5 +27,51 @@ public class Version {
public static final String PLUGINS_URL = "http://www.azib.net/ipscan/plugins/";
public static final String LATEST_VERSION_URL = "http://www.azib.net/ipscan/IPSCAN.VERSION";
public static final String LATEST_VERSION_URL = "http://www.azib.net/ipscan/IPSCAN.VERSION";
private static String version;
private static String build;
/**
* @return version of currently running Angry IP Scanner (retrieved from the jar file)
*/
public static String getVersion() {
if (version == null) {
loadVersionFromJar();
}
return version;
}
/**
* @return build number of currently running Angry IP Scanner (retrieved from the jar file)
*/
public static String getBuildNumber() {
if (build == null) {
loadVersionFromJar();
}
return build;
}
private static void loadVersionFromJar() {
String path = Version.class.getClassLoader().getResource(Version.class.getName().replace('.', '/') + ".class").toString();
if (path.startsWith("jar:file:")) {
path = path.substring(4, path.indexOf('!'));
try {
JarFile jarFile = new JarFile(new URI(path).getPath());
Attributes attrs = jarFile.getManifest().getMainAttributes();
version = attrs.getValue("Version");
build = attrs.getValue("Build");
return;
}
catch (Exception e) {
LoggerFactory.getLogger().log(Level.WARNING, "Cannot obtain version", e);
}
}
version = "Current";
build = "unknown";
}
public static String getFullName() {
return NAME + " " + getVersion();
}
}

View File

@ -55,7 +55,7 @@ public class TXTExporter implements Exporter {
output = new OutputStreamWriter(outputStream, Labels.getLabel("encoding"));
if (!isAppend) {
output.write(Labels.getLabel("exporter.txt.generated"));
println(Version.FULL_NAME);
println(Version.getFullName());
println(Version.WEBSITE);
output.write(NEWLINE);

View File

@ -56,7 +56,7 @@ public class XMLExporter implements Exporter {
public void start(OutputStream outputStream, String feederInfo) throws IOException {
output = new PrintWriter(new OutputStreamWriter(outputStream, ENCODING));
output.println("<?xml version=\"1.0\" encoding=\"" + ENCODING + "\" standalone=\"yes\"?>");
output.println("<!-- This file has been generated by " + Version.FULL_NAME + " -->");
output.println("<!-- This file has been generated by " + Version.getFullName() + " -->");
output.println("<!-- Visit the website at " + Version.WEBSITE + " -->");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

View File

@ -51,7 +51,8 @@ public class AboutDialog extends AbstractModalDialog {
Link textLabel = new Link(shell, SWT.NONE);
String text = Labels.getLabel("text.about");
text = text.replaceAll("%NAME", Version.NAME);
text = text.replaceAll("%VERSION", Version.VERSION);
text = text.replaceAll("%VERSION", Version.getVersion());
text = text.replaceAll("%BUILD", Version.getBuildNumber());
text = text.replaceAll("%COPYLEFT", Version.COPYLEFT);
text = text.replaceAll("%WEBSITE", Version.WEBSITE);
text = text.replaceAll("%MAILTO", Version.MAILTO);

View File

@ -82,12 +82,12 @@ public class HelpActions {
reader.close();
MessageBox messageBox = new MessageBox(event.display.getActiveShell(), SWT.ICON_INFORMATION);
messageBox.setText(Version.FULL_NAME);
messageBox.setText(Version.getFullName());
if (!Version.VERSION.equals(latestVersion)) {
if (!Version.getVersion().equals(latestVersion)) {
String message = Labels.getLabel("text.version.old");
message = message.replaceFirst("%LATEST", latestVersion);
message = message.replaceFirst("%VERSION", Version.VERSION);
message = message.replaceFirst("%VERSION", Version.getVersion());
messageBox.setMessage(message);
}
else {

View File

@ -35,7 +35,7 @@ public class TXTExporterTest extends AbstractExporterTestCase {
public void testHeaderWithoutAppend() throws IOException {
exporter.start(outputStream, "feederstuff");
exporter.end();
assertContains(Version.FULL_NAME);
assertContains(Version.NAME);
assertContains(Version.WEBSITE);
}
@ -44,7 +44,7 @@ public class TXTExporterTest extends AbstractExporterTestCase {
exporter.setAppend(true);
exporter.start(outputStream, "feederstuff");
exporter.end();
assertNotContains(Version.FULL_NAME);
assertNotContains(Version.NAME);
assertNotContains(Version.WEBSITE);
}

View File

@ -40,7 +40,7 @@ public class XMLExporterTest extends AbstractExporterTestCase {
public void testHeaderWithoutAppend() throws IOException {
exporter.start(outputStream, "feederstuff");
exporter.end();
assertContains(Version.FULL_NAME);
assertContains(Version.NAME);
assertContains(Version.WEBSITE);
}