Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update library loading so branch not required for localSource locations. #75

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class LibraryConfiguration {
String targetPath

LibraryConfiguration validate() {
if (name && defaultVersion && retriever && targetPath)
if (name && retriever && targetPath && ((retriever instanceof LocalSource) || defaultVersion))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this class should be agnostic of the retriever's "type".

return this
throw new IllegalStateException("LibraryConfiguration is not properly initialized ${this.toString()}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ class LocalSource implements SourceRetriever {

@Override
List<URL> retrieve(String repository, String branch, String targetPath) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real problem here is that the (abstract) concept of SourceRetriever is too tightly coupled with the one of a (git) repository and that we are bending the implementation accordingly. Rather than always requiring a branch and ignoring it when it does not make sense (i.e. in line 18), it would be much better if the retrieve API had a more generic signature. For example, it could take take a single map instead of the repository/branch tuple. This would allow us to specialize the map according to the needs of the specific retriever.

def sourceDir = new File(sourceURL).toPath().resolve("$repository@$branch").toFile()
def sourceURLPath = new File(sourceURL).toPath()
def sourceDir
if (branch) {
sourceDir = sourceURLPath.resolve("$repository@$branch").toFile()
} else {
sourceDir = sourceURLPath.resolve(repository).toFile()
}

if (sourceDir.exists()) {
return [sourceDir.toURI().toURL()]
}
Expand Down