Skip to content

Commit 26dbf92

Browse files
gselzerctrueden
authored andcommitted
Create SciJava Discoverer Therapi
1 parent c3e7def commit 26dbf92

12 files changed

Lines changed: 239 additions & 48 deletions

File tree

‎pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<module>imagej/imagej-ops2</module>
4949
<module>imagej/imagej-testutil</module>
5050
<module>scijava/scijava-discovery</module>
51+
<module>scijava/scijava-discovery-therapi</module>
5152
<module>scijava/scijava-function</module>
5253
<module>scijava/scijava-ops-api</module>
5354
<module>scijava/scijava-ops-engine</module>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.apt_generated/
2+
/.apt_generated_tests/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2016 - 2019, SciJava Ops developers.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24+
POSSIBILITY OF SUCH DAMAGE.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SciJava Discovery: A library for the abstraction of service discovery mechanisms
2+
3+
This module provides the `Discoverer` interface, an abstraction for service discovery.
4+
5+
WIP
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.scijava</groupId>
9+
<artifactId>scijava-incubator</artifactId>
10+
<version>0-SNAPSHOT</version>
11+
<relativePath>../..</relativePath>
12+
</parent>
13+
14+
<artifactId>scijava-discovery-therapi</artifactId>
15+
16+
<name>SciJava Discovery Therapi</name>
17+
<description>SciJava Discovery Therapi: A therapi-aided Discovery implementation</description>
18+
<url>https://github.com/scijava/scijava</url>
19+
<inceptionYear>2021</inceptionYear>
20+
<organization>
21+
<name>SciJava</name>
22+
<url>https://scijava.org/</url>
23+
</organization>
24+
<licenses>
25+
<license>
26+
<name>Simplified BSD License</name>
27+
<distribution>repo</distribution>
28+
</license>
29+
</licenses>
30+
31+
<developers>
32+
<developer>
33+
<id>ctrueden</id>
34+
<name>Curtis Rueden</name>
35+
<url>https://imagej.net/User:Rueden</url>
36+
<roles>
37+
<role>founder</role>
38+
<role>reviewer</role>
39+
<role>support</role>
40+
<role>maintainer</role>
41+
</roles>
42+
</developer>
43+
<developer>
44+
<id>gselzer</id>
45+
<name>Gabriel Selzer</name>
46+
<roles>
47+
<role>founder</role>
48+
<role>lead</role>
49+
<role>developer</role>
50+
<role>debugger</role>
51+
<role>reviewer</role>
52+
<role>support</role>
53+
</roles>
54+
</developer>
55+
</developers>
56+
<contributors>
57+
<contributor>
58+
<name>None</name>
59+
</contributor>
60+
</contributors>
61+
62+
<mailingLists>
63+
<mailingList>
64+
<name>Image.sc Forum</name>
65+
<archive>https://forum.image.sc/tags/scijava-discovery-therapi</archive>
66+
</mailingList>
67+
</mailingLists>
68+
69+
<scm>
70+
<connection>scm:git:git://github.com/scijava/incubator</connection>
71+
<developerConnection>scm:git:git@github.com:scijava/incubator</developerConnection>
72+
<tag>HEAD</tag>
73+
<url>https://github.com/scijava/incubator</url>
74+
</scm>
75+
<issueManagement>
76+
<system>GitHub Issues</system>
77+
<url>https://github.com/scijava/scijava/issues</url>
78+
</issueManagement>
79+
<ciManagement>
80+
<system>Travis CI</system>
81+
<url>https://travis-ci.com/scijava/incubator</url>
82+
</ciManagement>
83+
84+
<properties>
85+
<package-name>org.scijava.discovery.therapi</package-name>
86+
87+
<license.licenseName>bsd_2</license.licenseName>
88+
<license.copyrightOwners>SciJava developers.</license.copyrightOwners>
89+
<scijava-discovery-therapi.allowedDuplicateClasses>
90+
${scijava.allowedDuplicateClasses}
91+
</scijava-discovery-therapi.allowedDuplicateClasses>
92+
<allowedDuplicateClasses>${scijava-discovery-therapi.allowedDuplicateClasses}</allowedDuplicateClasses>
93+
<therapi.packages></therapi.packages>
94+
</properties>
95+
<dependencies>
96+
<dependency>
97+
<groupId>org.scijava</groupId>
98+
<artifactId>scijava-discovery</artifactId>
99+
<version>${project.version}</version>
100+
</dependency>
101+
<dependency>
102+
<groupId>com.github.therapi</groupId>
103+
<artifactId>therapi-runtime-javadoc</artifactId>
104+
<version>${therapi-runtime-javadoc.version}</version>
105+
</dependency>
106+
<!-- Test scope dependencies -->
107+
<dependency>
108+
<groupId>junit</groupId>
109+
<artifactId>junit</artifactId>
110+
<scope>test</scope>
111+
</dependency>
112+
</dependencies>
113+
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module org.scijava.discovery.therapi {
2+
3+
exports org.scijava.discovery.therapi;
4+
opens org.scijava.discovery.therapi to therapi.runtime.javadoc;
5+
6+
requires org.scijava.discovery;
7+
requires therapi.runtime.javadoc;
8+
9+
provides org.scijava.discovery.Discoverer with org.scijava.discovery.therapi.TherapiDiscoverer;
10+
11+
}

scijava/scijava-ops-engine/src/main/java/org/scijava/ops/engine/impl/TherapiDiscoverer.java renamed to scijava/scijava-discovery-therapi/src/main/java/org/scijava/discovery/therapi/TherapiDiscoverer.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
package org.scijava.ops.engine.impl;
2+
package org.scijava.discovery.therapi;
33

44
import com.github.therapi.runtimejavadoc.BaseJavadoc;
55
import com.github.therapi.runtimejavadoc.ClassJavadoc;
@@ -11,6 +11,11 @@
1111
import java.lang.reflect.AnnotatedElement;
1212
import java.lang.reflect.Field;
1313
import java.lang.reflect.Method;
14+
import java.net.URI;
15+
import java.nio.file.FileSystem;
16+
import java.nio.file.FileSystems;
17+
import java.nio.file.Files;
18+
import java.nio.file.Path;
1419
import java.util.ArrayList;
1520
import java.util.Arrays;
1621
import java.util.Collections;
@@ -40,6 +45,8 @@ private static Class<?> getClass(String name) throws ClassNotFoundException {
4045
* class loader if non-null; otherwise it will be the system class loader.
4146
* <p>
4247
* Forked from SciJava Common's Context class.
48+
*
49+
* @implNote test
4350
*
4451
* @see Thread#getContextClassLoader()
4552
* @see ClassLoader#getSystemClassLoader()
@@ -213,7 +220,9 @@ public static List<File> getJavadocedFiles(String path) {
213220
else if (file.getPath().endsWith(".jar")) {
214221
try {
215222
for (String s : getJarContent(path))
216-
if (s.endsWith("__Javadoc.json")) filesList.add(file);
223+
if (s.endsWith("__Javadoc.json")) {
224+
filesList.add(new File(s));
225+
}
217226
}
218227
catch (IOException exc) {
219228
// TODO Auto-generated catch block
@@ -239,8 +248,12 @@ private static void recurse(List<File> filesList, File f) {
239248
}
240249

241250
private static String getFullyQualifiedName(File f, String path) {
251+
if (f.getPath().contains(path)) {
242252
return f.getPath().substring(path.length() + 1, f.getPath().indexOf(
243253
"__Javadoc.json")).replace(System.getProperty("file.separator"), ".");
254+
}
255+
return f.getPath().substring(0, f.getPath().indexOf(
256+
"__Javadoc.json")).replace(System.getProperty("file.separator"), ".");
244257
}
245258

246259
/**

scijava/scijava-ops-engine/src/test/java/org/scijava/ops/engine/impl/TherapiDiscovererTest.java renamed to scijava/scijava-discovery-therapi/src/test/java/org/scijava/discovery/therapi/TherapiDiscovererTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.scijava.ops.engine.impl;
1+
package org.scijava.discovery.therapi;
22

33
import java.lang.reflect.AnnotatedElement;
44
import java.util.List;
@@ -7,6 +7,7 @@
77

88
import org.junit.Assert;
99
import org.junit.Test;
10+
import org.scijava.discovery.therapi.TherapiDiscoverer;
1011
import org.scijava.discovery.Discovery;
1112

1213
public class TherapiDiscovererTest extends TherapiDiscoverer {

‎scijava/scijava-ops-engine/pom.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@
137137
<artifactId>scijava-discovery</artifactId>
138138
<version>${project.version}</version>
139139
</dependency>
140+
<dependency>
141+
<groupId>org.scijava</groupId>
142+
<artifactId>scijava-discovery-therapi</artifactId>
143+
<version>${project.version}</version>
144+
</dependency>
140145
<dependency>
141146
<groupId>org.scijava</groupId>
142147
<artifactId>scijava-ops-serviceloader</artifactId>

‎scijava/scijava-ops-engine/src/main/java/module-info.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
requires org.scijava;
3636
requires org.scijava.discovery;
37+
requires org.scijava.discovery.therapi;
3738
requires org.scijava.function;
3839
requires org.scijava.progress;
3940
requires org.scijava.struct;

0 commit comments

Comments
 (0)