Commit 9416ebfb authored by Claus Nagel's avatar Claus Nagel
Browse files

switched to Gradle

parent e248ab95
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* ade-xjc is part of the citygml4j project * ade-xjc is part of the citygml4j project
* *
* Copyright 2013-2017 Claus Nagel <claus.nagel@gmail.com> * Copyright 2013-2018 Claus Nagel <claus.nagel@gmail.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
--> -->
<xs:schema xmlns="http://www.igg.tu-berlin.de/citygml4j/ade_hooks" xmlns:xs="http://www.w3.org/2001/XMLSchema" <xs:schema xmlns="http://www.citygml4j.org/ade_hooks" xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.igg.tu-berlin.de/citygml4j/ade_hooks" targetNamespace="http://www.citygml4j.org/ade_hooks"
xmlns:core1="http://www.opengis.net/citygml/1.0" xmlns:app1="http://www.opengis.net/citygml/appearance/1.0" xmlns:core1="http://www.opengis.net/citygml/1.0" xmlns:app1="http://www.opengis.net/citygml/appearance/1.0"
xmlns:bldg1="http://www.opengis.net/citygml/building/1.0" xmlns:frn1="http://www.opengis.net/citygml/cityfurniture/1.0" xmlns:bldg1="http://www.opengis.net/citygml/building/1.0" xmlns:frn1="http://www.opengis.net/citygml/cityfurniture/1.0"
xmlns:grp1="http://www.opengis.net/citygml/cityobjectgroup/1.0" xmlns:luse1="http://www.opengis.net/citygml/landuse/1.0" xmlns:grp1="http://www.opengis.net/citygml/cityobjectgroup/1.0" xmlns:luse1="http://www.opengis.net/citygml/landuse/1.0"
......
...@@ -46,5 +46,5 @@ ...@@ -46,5 +46,5 @@
<xs:import namespace="http://www.opengis.net/citygml/waterbody/2.0" schemaLocation="2.0.0/waterBody.xsd"/> <xs:import namespace="http://www.opengis.net/citygml/waterbody/2.0" schemaLocation="2.0.0/waterBody.xsd"/>
<xs:import namespace="http://www.opengis.net/citygml/texturedsurface/2.0" schemaLocation="2.0.0/texturedSurface.xsd"/> <xs:import namespace="http://www.opengis.net/citygml/texturedsurface/2.0" schemaLocation="2.0.0/texturedSurface.xsd"/>
<!-- ade hooks --> <!-- ade hooks -->
<xs:import namespace="http://www.igg.tu-berlin.de/citygml4j/ade_hooks" schemaLocation="ade_hooks/ade_hooks.xsd"/> <xs:import namespace="http://www.citygml4j.org/ade_hooks" schemaLocation="ade_hooks/ade_hooks.xsd"/>
</xs:schema> </xs:schema>
rootProject.name = 'ade-xjc'
...@@ -32,17 +32,17 @@ public class FileDeleter extends SimpleFileVisitor<Path> { ...@@ -32,17 +32,17 @@ public class FileDeleter extends SimpleFileVisitor<Path> {
private boolean recursive; private boolean recursive;
private boolean onlyEmptyDirs; private boolean onlyEmptyDirs;
public FileDeleter(boolean recursive) { FileDeleter(boolean recursive) {
this(recursive, false); this(recursive, false);
} }
public FileDeleter(boolean recursive, boolean onlyEmptyDirs) { FileDeleter(boolean recursive, boolean onlyEmptyDirs) {
this.recursive = recursive; this.recursive = recursive;
this.onlyEmptyDirs = onlyEmptyDirs; this.onlyEmptyDirs = onlyEmptyDirs;
} }
boolean deleteFile(Path file) throws IOException { private void deleteFile(Path file) throws IOException {
return Files.deleteIfExists(file); Files.deleteIfExists(file);
} }
@Override @Override
...@@ -54,7 +54,7 @@ public class FileDeleter extends SimpleFileVisitor<Path> { ...@@ -54,7 +54,7 @@ public class FileDeleter extends SimpleFileVisitor<Path> {
} }
@Override @Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} }
...@@ -77,7 +77,7 @@ public class FileDeleter extends SimpleFileVisitor<Path> { ...@@ -77,7 +77,7 @@ public class FileDeleter extends SimpleFileVisitor<Path> {
} }
@Override @Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { public FileVisitResult visitFileFailed(Path file, IOException exc) {
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} }
......
/* /*
* ade-xjc - XML Schema binding compiler for CityGML ADEs * ade-xjc - XML Schema binding compiler for CityGML ADEs
* https://github.com/citygml4j/ade-xjc * https://github.com/citygml4j/ade-xjc
* *
* ade-xjc is part of the citygml4j project * ade-xjc is part of the citygml4j project
* *
* Copyright 2013-2017 Claus Nagel <claus.nagel@gmail.com> * Copyright 2013-2017 Claus Nagel <claus.nagel@gmail.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.citygml4j.ade_xjc; package org.citygml4j.ade_xjc;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileInputStream;
import java.io.FileInputStream; import java.io.IOException;
import java.io.FileNotFoundException; import java.io.InputStream;
import java.io.IOException; import java.math.BigInteger;
import java.io.InputStream; import java.net.MalformedURLException;
import java.math.BigInteger; import java.net.URL;
import java.net.MalformedURLException; import java.nio.file.Path;
import java.net.URL; import java.security.MessageDigest;
import java.nio.file.Path; import java.security.NoSuchAlgorithmException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; public class Util {
public class Util { public static BigInteger dir2md5(File file, BigInteger md5) throws NoSuchAlgorithmException {
md5 = string2md5(file.getName(), md5);
public static BigInteger dir2md5(File file, BigInteger md5) throws NoSuchAlgorithmException, FileNotFoundException {
md5 = string2md5(file.getName(), md5); if (file.isDirectory()) {
File[] children = file.listFiles(pathname -> pathname.isDirectory()
if (file.isDirectory()) { || pathname.getName().endsWith("xsd")
File[] children = file.listFiles(new FileFilter() { || pathname.getName().endsWith("xjb"));
public boolean accept(File pathname) {
if (pathname.isDirectory()) if (children != null) {
return true; for (File next : children)
md5 = dir2md5(next, md5);
if (pathname.getName().endsWith("xsd") || pathname.getName().endsWith("xjb")) }
return true; } else
md5 = file2md5(file.getAbsolutePath(), md5);
return false;
} return md5;
}); }
for (File next : children) private static BigInteger file2md5(String fileName, BigInteger md5) throws NoSuchAlgorithmException {
md5 = dir2md5(next, md5); MessageDigest digest = MessageDigest.getInstance("MD5");
byte[] buffer = new byte[8192];
} else int read;
md5 = file2md5(file.getAbsolutePath(), md5);
try (InputStream is = new FileInputStream(new File(fileName))) {
return md5; while( (read = is.read(buffer)) > 0)
} digest.update(buffer, 0, read);
public static BigInteger file2md5(String fileName, BigInteger md5) throws NoSuchAlgorithmException, FileNotFoundException { byte[] md5sum = digest.digest();
MessageDigest digest = MessageDigest.getInstance("MD5");
InputStream is = new FileInputStream(new File(fileName)); return md5.xor(new BigInteger(1, md5sum));
byte[] buffer = new byte[8192]; } catch(IOException e) {
int read = 0; throw new RuntimeException("Unable to process file for MD5", e);
}
try { }
while( (read = is.read(buffer)) > 0)
digest.update(buffer, 0, read); private static BigInteger string2md5(String input, BigInteger md5) throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("MD5");
byte[] md5sum = digest.digest(); byte[] md5sum = digest.digest(input.getBytes());
return md5.xor(new BigInteger(1, md5sum)); return md5.xor(new BigInteger(1, md5sum));
} catch(IOException e) { }
throw new RuntimeException("Unable to process file for MD5", e);
} finally { public static class URLClassLoader extends java.net.URLClassLoader {
try { URLClassLoader() {
is.close(); super(new URL[]{}, ADESchemaCompiler.class.getClassLoader());
} }
catch(IOException e) {
throw new RuntimeException("Unable to close input stream for MD5 calculation", e); @Override
} protected void addURL(URL url) {
} super.addURL(url);
} }
private static BigInteger string2md5(String input, BigInteger md5) throws NoSuchAlgorithmException { void addPath(Path path) {
MessageDigest digest = MessageDigest.getInstance("MD5"); try {
byte[] md5sum = digest.digest(input.getBytes()); super.addURL(path.toUri().toURL());
} catch (MalformedURLException e) {
return md5.xor(new BigInteger(1, md5sum)); //
} }
}
public static class URLClassLoader extends java.net.URLClassLoader { }
protected URLClassLoader() {
super(new URL[]{}, Util.class.getClassLoader()); }
}
@Override
protected void addURL(URL url) {
super.addURL(url);
}
protected void addPath(Path path) {
try {
super.addURL(path.toUri().toURL());
} catch (MalformedURLException e) {
//
}
}
}
}
/* /*
* ade-xjc - XML Schema binding compiler for CityGML ADEs * ade-xjc - XML Schema binding compiler for CityGML ADEs
* https://github.com/citygml4j/ade-xjc * https://github.com/citygml4j/ade-xjc
* *
* ade-xjc is part of the citygml4j project * ade-xjc is part of the citygml4j project
* *
* Copyright 2013-2017 Claus Nagel <claus.nagel@gmail.com> * Copyright 2013-2017 Claus Nagel <claus.nagel@gmail.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.citygml4j.ade_xjc; package org.citygml4j.ade_xjc;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
import com.sun.tools.xjc.api.ErrorListener; import com.sun.tools.xjc.api.ErrorListener;
public class XJCErrorListener implements ErrorListener { public class XJCErrorListener implements ErrorListener {
public void error(SAXParseException ex) { public void error(SAXParseException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
public void fatalError(SAXParseException ex) { public void fatalError(SAXParseException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
public void info(SAXParseException ex) { public void info(SAXParseException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
public void warning(SAXParseException ex) { public void warning(SAXParseException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment