[mvn] handle weird xml

Summary:
Fixes #683

Disclaimer: I don't know what XML namespaces/namespace prefixes are, but this seems to do the trick.

Reviewed By: mbouaziz

Differential Revision: D5381480

fbshipit-source-id: 3da16e7
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 50dc0bcad4
commit 3ed48e3196

@ -116,11 +116,16 @@ let add_infer_profile mvn_pom infer_pom =
let ic = In_channel.create mvn_pom in
let with_oc out_chan =
let with_ic () =
let xml_in = Xmlm.make_input ~strip:false (`Channel ic) in
let xml_out = Xmlm.make_output ~nl:true (`Channel out_chan) in
let xml_in = Xmlm.make_input ~strip:false (`Channel ic)
~ns:(fun ns -> Some ns) (* be generous with namespaces *) in
let xml_out = Xmlm.make_output ~nl:true (`Channel out_chan)
~ns_prefix:(fun prefix -> Some prefix) (* be generous with namespaces *) in
add_infer_profile_to_xml (Filename.dirname mvn_pom) xml_in xml_out in
protect ~f:with_ic ~finally:(fun () -> In_channel.close ic) in
Utils.with_file_out infer_pom ~f:with_oc
try Utils.with_file_out infer_pom ~f:with_oc
with Xmlm.Error ((line, col), error) as exn ->
L.external_error "%s:%d:%d: ERROR: %s@." mvn_pom line col (Xmlm.error_message error);
raise exn
let add_profile_to_pom_in_directory dir =
(* Even though there is a "-f" command-line arguments to change the config file Maven reads from,

@ -10,4 +10,26 @@
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>module2</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
<compilerArguments>
<Xlint:all/>
<Werror/>
</compilerArguments>
</configuration>
</plugin>
</plugins>
<resources>
</resources>
<pluginManagement>
</pluginManagement>
</build>
</project>

Loading…
Cancel
Save