Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

115 widen xml #116

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion transformer/.settings/org.eclipse.jdt.ui.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ cleanup.use_type_arguments=false
cleanup_profile=_bnd
cleanup_settings_version=2
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false
formatter_profile=_bnd
formatter_settings_version=16
org.eclipse.jdt.ui.exception.name=e
Expand Down
65 changes: 36 additions & 29 deletions transformer/src/main/java/org/eclipse/transformer/Transformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@
import org.eclipse.transformer.action.impl.SelectionRuleImpl;
import org.eclipse.transformer.action.impl.ServiceLoaderConfigActionImpl;
import org.eclipse.transformer.action.impl.SignatureRuleImpl;
import org.eclipse.transformer.action.impl.TextActionImpl;
import org.eclipse.transformer.action.impl.WarActionImpl;
import org.eclipse.transformer.action.impl.XmlActionImpl;
// import org.eclipse.transformer.action.impl.XmlActionImpl;
import org.eclipse.transformer.action.impl.ZipActionImpl;
import org.eclipse.transformer.util.FileUtils;

Expand Down Expand Up @@ -284,11 +285,15 @@ public static enum AppOption {
RULES_DIRECT("td", "direct", "Transformation direct string replacements",
OptionSettings.HAS_ARG, !OptionSettings.HAS_ARGS,
!OptionSettings.IS_REQUIRED, OptionSettings.NO_GROUP),
RULES_MASTER_XML("tf", "xml", "Map of XML filenames to property files",

RULES_MASTER_TEXT("tf", "xml", "Map of filenames to property files",
OptionSettings.HAS_ARG, !OptionSettings.HAS_ARGS,
!OptionSettings.IS_REQUIRED, OptionSettings.NO_GROUP),

// RULES_MASTER_XML("tf", "xml", "Map of XML filenames to property files",
// OptionSettings.HAS_ARG, !OptionSettings.HAS_ARGS,
// !OptionSettings.IS_REQUIRED, OptionSettings.NO_GROUP),

INVERT("i", "invert", "Invert transformation rules",
!OptionSettings.HAS_ARG, !OptionSettings.HAS_ARGS,
!OptionSettings.IS_REQUIRED, OptionSettings.NO_GROUP),
Expand Down Expand Up @@ -805,7 +810,7 @@ public class TransformOptions {
public Map<String, String> packageRenames;
public Map<String, String> packageVersions;
public Map<String, BundleData> bundleUpdates;
public Map<String, Map<String, String>> masterXmlUpdates; // ( pattern -> ( initial -> final ) )
public Map<String, Map<String, String>> masterTextUpdates; // ( pattern -> ( initial -> final ) )
public Map<String, String> directStrings;

public CompositeActionImpl rootAction;
Expand Down Expand Up @@ -874,7 +879,7 @@ public boolean setRules() throws IOException, URISyntaxException, IllegalArgumen
UTF8Properties versionProperties = loadProperties(AppOption.RULES_VERSIONS);
UTF8Properties updateProperties = loadProperties(AppOption.RULES_BUNDLES);
UTF8Properties directProperties = loadProperties(AppOption.RULES_DIRECT);
UTF8Properties xmlMasterProperties = loadProperties(AppOption.RULES_MASTER_XML);
UTF8Properties textMasterProperties = loadProperties(AppOption.RULES_MASTER_TEXT);

invert = hasOption(AppOption.INVERT);

Expand Down Expand Up @@ -918,22 +923,22 @@ public boolean setRules() throws IOException, URISyntaxException, IllegalArgumen
dual_info("Bundle identities will not be updated");
}

if ( !xmlMasterProperties.isEmpty() ) {
String masterXmlRef = getOptionValue(AppOption.RULES_MASTER_XML, DO_NORMALIZE);
if ( !textMasterProperties.isEmpty() ) {
String masterTextRef = getOptionValue(AppOption.RULES_MASTER_TEXT, DO_NORMALIZE);

Map<String, String> substitutionRefs =
TransformProperties.convertPropertiesToMap(xmlMasterProperties); // throws IllegalArgumentException
TransformProperties.convertPropertiesToMap(textMasterProperties); // throws IllegalArgumentException

Map<String, Map<String, String>> masterUpdates = new HashMap<String, Map<String, String>>();
for ( Map.Entry<String, String> substitutionRefEntry : substitutionRefs.entrySet() ) {
String simpleNameSelector = substitutionRefEntry.getKey();
String substitutionsRef = FileUtils.normalize( substitutionRefEntry.getValue() );

UTF8Properties substitutions;
if ( masterXmlRef == null ) {
if ( masterTextRef == null ) {
substitutions = loadInternalProperties("Substitions matching [ " + simpleNameSelector + " ]", substitutionsRef);
} else {
String relativeSubstitutionsRef = relativize(substitutionsRef, masterXmlRef);
String relativeSubstitutionsRef = relativize(substitutionsRef, masterTextRef);
if ( !relativeSubstitutionsRef.equals(substitutionsRef) ) {
dual_info(
"Adjusted substition reference from [ %s ] to [ %s ]",
Expand All @@ -946,12 +951,12 @@ public boolean setRules() throws IOException, URISyntaxException, IllegalArgumen
masterUpdates.put(simpleNameSelector, substitutionsMap);
}

masterXmlUpdates = masterUpdates;
dual_info("XML files will be updated");
masterTextUpdates = masterUpdates;
dual_info("Text files will be updated");

} else {
masterXmlUpdates = null;
dual_info("XML files will not be updated");
masterTextUpdates = null;
dual_info("Text files will not be updated");
}

if ( !directProperties.isEmpty() ) {
Expand Down Expand Up @@ -1086,13 +1091,13 @@ protected void logRules() {
}
}

info("XML substitutions:");
if ( (masterXmlUpdates == null) || masterXmlUpdates.isEmpty() ) {
info("Text substitutions:");
if ( (masterTextUpdates == null) || masterTextUpdates.isEmpty() ) {
info(" [ ** NONE ** ]");
} else {
for ( Map.Entry<String, Map<String, String>> masterXmlEntry : masterXmlUpdates.entrySet() ) {
info(" Pattern [ " + masterXmlEntry.getKey() + " ]");
for ( Map.Entry<String, String> substitution : masterXmlEntry.getValue().entrySet() ) {
for ( Map.Entry<String, Map<String, String>> masterTextEntry : masterTextUpdates.entrySet() ) {
info(" Pattern [ " + masterTextEntry.getKey() + " ]");
for ( Map.Entry<String, String> substitution : masterTextEntry.getValue().entrySet() ) {
info(" [ " + substitution.getKey() + " ]: [ " + substitution.getValue() + " ]");
}
}
Expand All @@ -1117,7 +1122,7 @@ protected SignatureRuleImpl getSignatureRule() {
packageRenames,
packageVersions,
bundleUpdates,
masterXmlUpdates,
masterTextUpdates,
directStrings);
}
return signatureRules;
Expand Down Expand Up @@ -1267,9 +1272,11 @@ public CompositeActionImpl getRootAction() {
EarActionImpl earAction =
useRootAction.addUsing( EarActionImpl::new );

XmlActionImpl xmlAction =
useRootAction.addUsing( XmlActionImpl::new );

TextActionImpl textAction =
useRootAction.addUsing( TextActionImpl::new );
// XmlActionImpl xmlAction =
// useRootAction.addUsing( XmlActionImpl::new );

ZipActionImpl zipAction =
useRootAction.addUsing( ZipActionImpl::new );

Expand All @@ -1288,15 +1295,15 @@ public CompositeActionImpl getRootAction() {
directoryAction.addAction(warAction);
directoryAction.addAction(rarAction);
directoryAction.addAction(earAction);
directoryAction.addAction(xmlAction);
directoryAction.addAction(textAction);
directoryAction.addAction(nullAction);

jarAction.addAction(classAction);
jarAction.addAction(javaAction);
jarAction.addAction(serviceConfigAction);
jarAction.addAction(manifestAction);
jarAction.addAction(featureAction);
jarAction.addAction(xmlAction);
jarAction.addAction(textAction);
jarAction.addAction(nullAction);

warAction.addAction(classAction);
Expand All @@ -1305,7 +1312,7 @@ public CompositeActionImpl getRootAction() {
warAction.addAction(manifestAction);
warAction.addAction(featureAction);
warAction.addAction(jarAction);
warAction.addAction(xmlAction);
warAction.addAction(textAction);
warAction.addAction(nullAction);

rarAction.addAction(classAction);
Expand All @@ -1314,14 +1321,14 @@ public CompositeActionImpl getRootAction() {
rarAction.addAction(manifestAction);
rarAction.addAction(featureAction);
rarAction.addAction(jarAction);
rarAction.addAction(xmlAction);
rarAction.addAction(textAction);
rarAction.addAction(nullAction);

earAction.addAction(manifestAction);
earAction.addAction(jarAction);
earAction.addAction(warAction);
earAction.addAction(rarAction);
earAction.addAction(xmlAction);
earAction.addAction(textAction);
earAction.addAction(nullAction);

zipAction.addAction(classAction);
Expand All @@ -1333,7 +1340,7 @@ public CompositeActionImpl getRootAction() {
zipAction.addAction(warAction);
zipAction.addAction(rarAction);
zipAction.addAction(earAction);
zipAction.addAction(xmlAction);
zipAction.addAction(textAction);
zipAction.addAction(nullAction);

rootAction = useRootAction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public enum ActionType {
CLASS,
MANIFEST, FEATURE,
SERVICE_LOADER_CONFIG,
XML,
TEXT,
// XML,

ZIP, JAR, WAR, RAR, EAR,
JAVA,
Expand Down
Loading