use of org.jboss.jandex.JarIndexer in project core by weld.
the class BeanDiscoveryWithJandexIndexTest method createJandexIndexAsset.
/**
* Exports the JavaArchive to a temporary file and uses {@link JarIndexer} to write an jandex.idx file.
*/
private static Asset createJandexIndexAsset(JavaArchive archiveToIndex) {
Asset jandexIndexAsset = EmptyAsset.INSTANCE;
try {
final File tempJarFile = File.createTempFile("BeanDiscoveryWithJandexIndexTest", ".jar");
tempJarFile.deleteOnExit();
archiveToIndex.as(ZipExporter.class).exportTo(tempJarFile, true);
final Indexer indexer = new Indexer();
final Result result = JarIndexer.createJarIndex(tempJarFile, indexer, false, false, false);
final File indexFile = result.getOutputFile();
indexFile.deleteOnExit();
jandexIndexAsset = new FileAsset(indexFile);
} catch (IOException e) {
throw new RuntimeException(e);
}
return jandexIndexAsset;
}
Aggregations