-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
transcoder: decrease the dependencies of the
api
and tosvg
transc…
…oders
- Loading branch information
Showing
104 changed files
with
1,835 additions
and
1,037 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
plugins { | ||
id 'echosvg.java-conventions' | ||
} | ||
|
||
sourceSets { | ||
// Tests | ||
test { | ||
resources.srcDirs += ["$rootDir/test-resources"] | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':echosvg-awt-util') | ||
implementation project(':echosvg-i18n') | ||
implementation "io.sf.jclf:jclf-text:${jclfTextVersion}" | ||
implementation "io.sf.carte:xml-dtd:${xmlDtdVersion}" | ||
implementation "io.sf.carte:carte-util:${carteUtilVersion}" | ||
|
||
testRuntimeOnly project(':echosvg-codec') | ||
testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}" | ||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
} | ||
|
||
description = 'io.sf.carte:echosvg-test-util' | ||
|
||
publishing.publications.maven(MavenPublication).pom { | ||
description = "EchoSVG testing utilities" | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
||
tasks.withType(ProcessResources).configureEach { | ||
dependsOn ':echosvg-test-scripts:copyScriptJars',':echosvg-test-scripts:copyPolicyJar' | ||
} |
File renamed without changes.
File renamed without changes.
99 changes: 99 additions & 0 deletions
99
echosvg-test-util/src/main/java/io/sf/carte/echosvg/test/TestUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* | ||
* See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. | ||
* | ||
*/ | ||
package io.sf.carte.echosvg.test; | ||
|
||
import java.io.File; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.nio.file.Paths; | ||
|
||
public class TestUtil { | ||
|
||
private TestUtil() { | ||
} | ||
|
||
/** | ||
* Get the URL of the root project directory. | ||
* | ||
* @param cl a class provided by the project. | ||
* @param projectDirname the directory name of the subproject from which this is | ||
* executed. | ||
* @return the URL. | ||
*/ | ||
public static String getRootProjectURL(Class<?> cl, String projectDirname) { | ||
String resName = cl.getName().replace(".", "/") + ".class"; | ||
URL url = ResourceLoader.getInstance().getResource(cl, resName); | ||
if (url == null) { | ||
url = cwdURL(); | ||
} | ||
String sUrl = url.toExternalForm(); | ||
int testDirIdx = sUrl.lastIndexOf(projectDirname); | ||
if (testDirIdx != -1) { | ||
sUrl = sUrl.substring(0, testDirIdx); | ||
} // If no projectDirname, we probably got the root via CWD | ||
return sUrl; | ||
} | ||
|
||
private static URL cwdURL() { | ||
try { | ||
return Paths.get(".").toAbsolutePath().normalize().toUri().toURL(); | ||
} catch (MalformedURLException e) { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Get the URL of the Gradle-style project build directory. | ||
* | ||
* @param cl a class provided by the project. | ||
* @param projectDirname the directory name of the subproject from which this is | ||
* executed. | ||
* @return the URL. | ||
*/ | ||
public static String getProjectBuildURL(Class<?> cl, String projectDirname) { | ||
String resName = cl.getName().replace(".", "/") + ".class"; | ||
URL url = ResourceLoader.getInstance().getResource(cl, resName); | ||
String classUrl; | ||
if (url == null) { | ||
url = cwdURL(); | ||
File f = new File(url.getFile(), projectDirname); | ||
if (f.exists()) { | ||
// CWD is root directory | ||
try { | ||
url = new URL(url.getProtocol(), url.getHost(), url.getPort(), f.getAbsolutePath()); | ||
} catch (MalformedURLException e) { | ||
return null; | ||
} | ||
classUrl = url.toExternalForm(); | ||
} else { | ||
// CWD is the project directory instead of root | ||
classUrl = url.toExternalForm(); | ||
if (classUrl.lastIndexOf(projectDirname) == -1) { | ||
return null; | ||
} | ||
} | ||
} else { | ||
classUrl = url.toExternalForm(); | ||
} | ||
int testDirIdx = classUrl.lastIndexOf(projectDirname); | ||
String buildDir = classUrl.substring(5, testDirIdx + projectDirname.length()) + "/build/"; | ||
return buildDir; | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
echosvg-test-util/src/main/java/io/sf/carte/echosvg/test/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
See the NOTICE file distributed with this work for additional | ||
information regarding copyright ownership. | ||
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. | ||
*/ | ||
|
||
/** | ||
* Generic testing utilities. | ||
*/ | ||
package io.sf.carte.echosvg.test; |
Oops, something went wrong.