use of org.jetbrains.plugins.javaFX.packaging.JavaFxArtifactProperties in project intellij-community by JetBrains.
the class JavaFxChunkBuildExtension method generateTasksForArtifact.
@Override
public void generateTasksForArtifact(Artifact artifact, boolean preprocessing, ArtifactAntGenerationContext context, CompositeGenerator generator) {
if (preprocessing)
return;
if (!(artifact.getArtifactType() instanceof JavaFxApplicationArtifactType))
return;
final CompositePackagingElement<?> rootElement = artifact.getRootElement();
final List<PackagingElement<?>> children = new ArrayList<>();
String artifactFileName = rootElement.getName();
for (PackagingElement<?> child : rootElement.getChildren()) {
if (child instanceof ArchivePackagingElement) {
artifactFileName = ((ArchivePackagingElement) child).getArchiveFileName();
children.addAll(((ArchivePackagingElement) child).getChildren());
} else {
children.add(child);
}
}
final String artifactName = FileUtil.getNameWithoutExtension(artifactFileName);
final String tempDirPath = BuildProperties.propertyRef(context.createNewTempFileProperty("artifact.temp.output." + artifactName, artifactFileName));
final PackagingElementResolvingContext resolvingContext = ArtifactManager.getInstance(context.getProject()).getResolvingContext();
for (Generator childGenerator : computeChildrenGenerators(resolvingContext, new DirectoryAntCopyInstructionCreator(tempDirPath), context, artifact.getArtifactType(), children)) {
generator.add(childGenerator);
}
final JavaFxArtifactProperties properties = (JavaFxArtifactProperties) artifact.getProperties(JavaFxArtifactPropertiesProvider.getInstance());
final JavaFxArtifactProperties.JavaFxPackager javaFxPackager = new JavaFxArtifactProperties.JavaFxPackager(artifact, properties, context.getProject()) {
@Override
protected void registerJavaFxPackagerError(String message) {
}
};
final String tempDirDeployPath = tempDirPath + "/deploy";
final List<JavaFxAntGenerator.SimpleTag> tags = JavaFxAntGenerator.createJarAndDeployTasks(javaFxPackager, artifactFileName, artifact.getName(), tempDirPath, tempDirDeployPath, context.getProject().getBasePath());
for (JavaFxAntGenerator.SimpleTag tag : tags) {
buildTags(generator, tag);
}
if (properties.isEnabledSigning()) {
final boolean selfSigning = properties.isSelfSigning();
String vendor = properties.getVendor();
if (vendor != null) {
vendor = vendor.replaceAll(",", "\\\\,");
}
generator.add(new Property(artifactBasedProperty(ARTIFACT_VENDOR_SIGN_PROPERTY, artifactName), "CN=" + vendor));
final String alias = selfSigning ? "jb" : properties.getAlias();
generator.add(new Property(artifactBasedProperty(ARTIFACT_ALIAS_SIGN_PROPERTY, artifactName), alias));
final String keystore = selfSigning ? tempDirPath + File.separator + "jb-key.jks" : properties.getKeystore();
generator.add(new Property(artifactBasedProperty(ARTIFACT_KEYSTORE_SIGN_PROPERTY, artifactName), keystore));
final String storepass = selfSigning ? "storepass" : new String(Base64.getDecoder().decode(properties.getStorepass()), StandardCharsets.UTF_8);
generator.add(new Property(artifactBasedProperty(ARTIFACT_STOREPASS_SIGN_PROPERTY, artifactName), storepass));
final String keypass = selfSigning ? "keypass" : new String(Base64.getDecoder().decode(properties.getKeypass()), StandardCharsets.UTF_8);
generator.add(new Property(artifactBasedProperty(ARTIFACTKEYPASS_SIGN_PROPERTY, artifactName), keypass));
final Pair[] keysDescriptions = createKeysDescriptions(artifactName);
if (selfSigning) {
generator.add(new Tag("genkey", ArrayUtil.prepend(Couple.of("dname", BuildProperties.propertyRef(artifactBasedProperty(ARTIFACT_VENDOR_SIGN_PROPERTY, artifactName))), keysDescriptions)));
}
final Tag signjar = new Tag("signjar", keysDescriptions);
final Tag fileset = new Tag("fileset", Couple.of("dir", tempDirDeployPath));
fileset.add(new Tag("include", Couple.of("name", "*.jar")));
signjar.add(fileset);
generator.add(signjar);
}
final DirectoryAntCopyInstructionCreator creator = new DirectoryAntCopyInstructionCreator(BuildProperties.propertyRef(context.getConfiguredArtifactOutputProperty(artifact)));
generator.add(creator.createDirectoryContentCopyInstruction(tempDirDeployPath));
final Tag deleteTag = new Tag("delete", Couple.of("includeemptydirs", "true"));
deleteTag.add(new Tag("fileset", Couple.of("dir", tempDirPath)));
generator.add(deleteTag);
}
Aggregations