Skip to content

Commit

Permalink
TEZ-3322: Add Apache license to the generated tez-configuration-templ…
Browse files Browse the repository at this point in the history
…ate files (#230). (Laszlo Bodor, reviewed by Ayush Saxena)
  • Loading branch information
abstractdog authored Aug 18, 2024
1 parent cd6ceec commit a66c903
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.tez.tools.javadoc.model.Config;
import org.apache.tez.tools.javadoc.model.ConfigProperty;

import com.google.common.io.ByteStreams;

public class XmlWriter extends Writer {

public void write(Config config) throws IOException {
Expand All @@ -46,9 +49,10 @@ public void write(Config config) throws IOException {

try {
File file = new File(fileName);
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
writeApacheHeader(file);

out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file, true), "UTF-8"));

out.println("<?xml version=\"1.0\"?>");
out.println("<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>");
out.println();
out.println("<!-- WARNING: THIS IS A GENERATED TEMPLATE PURELY FOR DOCUMENTATION PURPOSES");
Expand Down Expand Up @@ -95,5 +99,10 @@ public void write(Config config) throws IOException {
}
}


private void writeApacheHeader(File file) throws IOException {
try (InputStream in = this.getClass().getClassLoader().getResourceAsStream("apache-licence.xml.header");
OutputStream out = new FileOutputStream(file)) {
ByteStreams.copy(in, out);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file.
-->

0 comments on commit a66c903

Please sign in to comment.