use of org.jetbrains.osgi.jps.model.LibraryBundlificationRule in project intellij-plugins by JetBrains.
the class BndWrapper method wrap.
@Nullable
private File wrap(@NotNull File sourceFile, @NotNull File outputDir, @NotNull List<LibraryBundlificationRule> rules) throws OsgiBuildException {
if (!sourceFile.isFile()) {
throw new OsgiBuildException("The library '" + sourceFile + "' does not exist - please check module dependencies.");
}
File targetFile = new File(outputDir, sourceFile.getName());
Map<String, String> additionalProperties = ContainerUtil.newHashMap();
long lastModified = Long.MIN_VALUE;
for (LibraryBundlificationRule bundlificationRule : rules) {
if (bundlificationRule.appliesTo(sourceFile.getName())) {
if (bundlificationRule.isDoNotBundle()) {
return null;
}
additionalProperties.putAll(bundlificationRule.getAdditionalPropertiesMap());
lastModified = Math.max(lastModified, bundlificationRule.getLastModified());
if (bundlificationRule.isStopAfterThisRule()) {
break;
}
}
}
if (targetFile.exists() && targetFile.lastModified() >= sourceFile.lastModified() && targetFile.lastModified() >= lastModified) {
return targetFile;
}
doWrap(sourceFile, targetFile, additionalProperties);
return targetFile;
}
use of org.jetbrains.osgi.jps.model.LibraryBundlificationRule in project intellij-plugins by JetBrains.
the class LibraryBundlificationRuleTest method testEqual.
@Test
public void testEqual() throws Exception {
LibraryBundlificationRule rule1 = new LibraryBundlificationRule();
LibraryBundlificationRule rule2 = new LibraryBundlificationRule();
assertTrue(rule1.equals(rule2));
rule1.setRuleRegex(".+\\.jar");
rule2.setRuleRegex(".+\\.zip");
assertFalse(rule1.equals(rule2));
}
use of org.jetbrains.osgi.jps.model.LibraryBundlificationRule in project intellij-plugins by JetBrains.
the class BundleCompiler method bundlifyLibraries.
/**
* Bundlifies all libraries that belong to the given module and that are not bundles.
* The bundles are cached, so if the source library does not change, it will not be bundlified again.
* Returns a string array containing paths of the bundlified libraries.
*/
@NotNull
public List<String> bundlifyLibraries(@NotNull Module module) throws OsgiBuildException {
myIndicator.setText("Bundling non-OSGi libraries for module '" + module.getName() + "'");
File outputDir = BndWrapper.getOutputDir(getModuleOutputDir(module));
List<LibraryBundlificationRule> libRules = ApplicationSettings.getInstance().getLibraryBundlificationRules();
List<String> paths = OrderEnumerator.orderEntries(module).withoutSdk().withoutModuleSourceEntries().withoutDepModules().productionOnly().runtimeOnly().recursively().exportedOnly().classes().getPathsList().getPathList();
List<File> files = ContainerUtil.map(paths, path -> new File(path));
return new BndWrapper(this).bundlifyLibraries(files, outputDir, libRules);
}
use of org.jetbrains.osgi.jps.model.LibraryBundlificationRule in project intellij-plugins by JetBrains.
the class LibraryBundlingEditorComponent method updateFields.
private void updateFields() {
int index = myRulesList.getSelectedIndex();
if (index >= 0 && index != myLastSelected) {
final LibraryBundlificationRule rule = myRulesModel.getElementAt(index);
myLibraryRegex.setText(rule.getRuleRegex());
UIUtil.invokeLaterIfNeeded(() -> myManifestEditor.setText(rule.getAdditionalProperties()));
myNeverBundle.setSelected(rule.isDoNotBundle());
myStopAfterThisRule.setSelected(rule.isStopAfterThisRule());
myLastSelected = index;
}
myLibraryRegex.setEnabled(index >= 0);
myManifestEditor.setEnabled(index >= 0);
myNeverBundle.setEnabled(index >= 0);
myStopAfterThisRule.setEnabled(index >= 0);
}
use of org.jetbrains.osgi.jps.model.LibraryBundlificationRule in project intellij-plugins by JetBrains.
the class LibraryBundlingEditorComponent method updateCurrentRule.
private void updateCurrentRule() {
if (myLastSelected >= 0 && myLastSelected < myRulesModel.getSize()) {
LibraryBundlificationRule newRule = new LibraryBundlificationRule();
newRule.setRuleRegex(myLibraryRegex.getText().trim());
newRule.setAdditionalProperties(myManifestEditor.getText().trim());
newRule.setDoNotBundle(myNeverBundle.isSelected());
newRule.setStopAfterThisRule(myStopAfterThisRule.isSelected());
if (!newRule.equals(myRulesModel.getElementAt(myLastSelected))) {
myRulesModel.setElementAt(newRule, myLastSelected);
}
}
}
Aggregations