use of net.jangaroo.exml.mojo.pom.PomConverter in project jangaroo-tools by CoreMedia.
the class ExmlToMxmlMojo method execute.
@Override
public void execute() throws MojoExecutionException {
boolean useNewPackagingType = extAsVersion != null && new DefaultArtifactVersion(extAsVersion).compareTo(EXT_AS_FIRST_SWC_ARTIFACT_VERSION) >= 0;
if (!renameOnly && (hasExmlConfiguration() || "jangaroo".equals(getProject().getPackaging()))) {
getLog().info("reading POM from " + getProject().getBasedir().getPath());
PomConverter pomConverter = new PomConverter(getProject().getBasedir());
getLog().info("removing exml-maven-plugin from POM");
pomConverter.removeExmlPlugin();
String newPackaging = useNewPackagingType ? "swc" : "jangaroo-pkg";
getLog().info("changing packaging from 'jangaroo' to '" + newPackaging + "'");
pomConverter.changePackaging(newPackaging);
if (useNewPackagingType) {
getLog().info("adding dependency type 'swc' to all compile dependencies");
pomConverter.addDependencyType(newPackaging);
}
getLog().info("updating POM at " + getProject().getBasedir().getPath());
pomConverter.writePom();
}
if (!isExmlProject()) {
getLog().info("not an EXML project, skipping MXML conversion");
return;
}
if (renameOnly) {
getLog().info("Renaming EXML files to MXML files");
try {
renameFiles(getSourceDirectory(), "exml", "mxml");
renameFiles(getTestSourceDirectory(), "exml", "mxml");
} catch (IOException e) {
throw new MojoExecutionException("error while renaming EXML files", e);
}
return;
}
if (alreadyRenamed) {
getLog().info("Renaming MXML files back to EXML files before running the conversion");
try {
renameFiles(getSourceDirectory(), "mxml", "exml");
renameFiles(getTestSourceDirectory(), "mxml", "exml");
} catch (IOException e) {
throw new MojoExecutionException("error while renaming files", e);
}
}
if (extAsVersion == null) {
throw new MojoExecutionException("exml-to-mxml needs an extAsVersion.");
}
Artifact extAsArtifact = resolveExtAsArtifact(extAsVersion, useNewPackagingType ? "swc" : "jar");
File extAsJar = extAsArtifact.getFile();
// Convert main EXML sources to MXML:
ExmlConfiguration config = createExmlConfiguration(getActionScriptClassPath(), Collections.singletonList(getSourceDirectory()), getGeneratedSourcesDirectory());
config.setExtAsJar(extAsJar);
new Exmlc(config).convertAllExmlToMxml();
// Also convert test EXML sources to MXML:
if (getTestSourceDirectory() != null && getTestSourceDirectory().exists()) {
ExmlConfiguration testConfig = createExmlConfiguration(getActionScriptTestClassPath(), Collections.singletonList(getTestSourceDirectory()), getGeneratedTestSourcesDirectory());
testConfig.setExtAsJar(extAsJar);
new Exmlc(testConfig).convertAllExmlToMxml();
}
}
Aggregations