-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize resolving manifests (#293)
* provide possibility to resolve HTTP and file manifests * declare task output * checkstyle
- Loading branch information
1 parent
bef0c68
commit ea7b387
Showing
7 changed files
with
264 additions
and
55 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
31 changes: 31 additions & 0 deletions
31
...c-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/DependencySourceFactory.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,31 @@ | ||
/* | ||
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.plugins.autodoc.tasks; | ||
|
||
import org.gradle.api.artifacts.Dependency; | ||
|
||
import java.net.URI; | ||
|
||
class DependencySourceFactory { | ||
public static DependencySource createDependencySource(URI uri, Dependency dependency, String classifier, String type) { | ||
if (uri.getScheme().equals("file")) { | ||
return new FileSource(dependency, uri, classifier, type); | ||
} else if (uri.getScheme().startsWith("http")) { | ||
return new HttpSource(dependency, uri, classifier, type); | ||
} else { | ||
throw new RuntimeException("Unknown URI scheme " + uri); | ||
} | ||
} | ||
} |
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
56 changes: 56 additions & 0 deletions
56
...utodoc/autodoc-plugin/src/main/java/org/eclipse/edc/plugins/autodoc/tasks/FileSource.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,56 @@ | ||
/* | ||
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.plugins.autodoc.tasks; | ||
|
||
import org.gradle.api.artifacts.Dependency; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.InputStream; | ||
import java.net.URI; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* A dependency that is represented in the local file system, e.g. the local Maven cache | ||
*/ | ||
public class FileSource extends DependencySource { | ||
/** | ||
* Instantiates a new file source | ||
* | ||
* @param dependency the dependency in question | ||
* @param uri the location where the physical file exists | ||
* @param classifier what type of dependency we have, e.g. sources, sources, manifest etc | ||
* @param type file extension | ||
*/ | ||
public FileSource(Dependency dependency, URI uri, String classifier, String type) { | ||
super(dependency, uri, classifier, type); | ||
} | ||
|
||
@Override | ||
public boolean exists() { | ||
return Files.exists(Path.of(uri())); | ||
} | ||
|
||
@Override | ||
public InputStream inputStream() { | ||
try { | ||
return new FileInputStream(new File(uri())); | ||
} catch (FileNotFoundException e) { | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.