blob: 683a784d2c74b5d5ef193c5f9efb1113a0128136 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import java.io.*;
import java.util.zip.*;
import java.util.jar.Manifest;
File file = new File( basedir, "target/sonar-it-extract-plugin-key-plugin-1.0.jar" );
if ( !file.isFile() )
{
throw new FileNotFoundException( "Could not find generated JAR: " + file );
}
ZipFile zipFile = new ZipFile(file);
InputStream input = null;
try {
input = zipFile.getInputStream(zipFile.getEntry("META-INF/MANIFEST.MF"));
Manifest manifest = new Manifest(input);
String key = manifest.getMainAttributes().getValue("Plugin-Key");
if (!key.equals("itextractpluginkey")) {
throw new Exception("Plugin key is not valid: " + key);
}
} finally {
zipFile.close();
input.close();
}
|