Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-br committed Jun 9, 2021
1 parent 4af820d commit e6fd978
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -432,30 +432,32 @@ private Set<InstallInstructionModel> buildMavenInstallInstructions(
remoteMavenRepository = new RemoteMavenRepository(flintGradlePlugin.getHttpClient(), entry.getValue());
}

if (!internalRepository.isInstalled(artifact)) {
// The artifact is not installed already, install it
if (remoteMavenRepository == null) {
// Can't download anything in offline mode
throw new RuntimeException("Missing artifact " + artifact + " in local repository, " +
"but working in offline mode");
}

boolean setupSource = !downloader.hasSource(remoteMavenRepository);
if (setupSource) {
// The download has the source not set already, add it now
downloader.addSource(remoteMavenRepository);
}

try {
// Install the artifact including dependencies
downloader.installArtifact(artifact, internalRepository);
} catch (IOException e) {
throw new FlintGradleException("Failed to install maven artifact", e);
}

if (setupSource) {
// We added the source, clean up afterwards
downloader.removeSource(remoteMavenRepository);
synchronized (internalRepository) {
if (!internalRepository.isInstalled(artifact)) {
// The artifact is not installed already, install it
if (remoteMavenRepository == null) {
// Can't download anything in offline mode
throw new RuntimeException("Missing artifact " + artifact + " in local repository, " +
"but working in offline mode");
}

boolean setupSource = !downloader.hasSource(remoteMavenRepository);
if (setupSource) {
// The download has the source not set already, add it now
downloader.addSource(remoteMavenRepository);
}

try {
// Install the artifact including dependencies
downloader.installArtifact(artifact, internalRepository);
} catch (IOException e) {
throw new FlintGradleException("Failed to install maven artifact", e);
}

if (setupSource) {
// We added the source, clean up afterwards
downloader.removeSource(remoteMavenRepository);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@ public synchronized void installAll(MavenArtifact artifact, SimpleMavenRepositor
}

if (installIfNotExists) {
// If the artifact is not installed locally, try to install it
if (!target.isInstalled(artifact) && !installArtifact(artifact, target) && artifactPom == null) {
// The artifact failed to install and there was also no POM for it
throw new MavenResolveException("Could not resolve " + artifact);
synchronized (target) {
// If the artifact is not installed locally, try to install it
if (!target.isInstalled(artifact) && !installArtifact(artifact, target) && artifactPom == null) {
// The artifact failed to install and there was also no POM for it
throw new MavenResolveException("Could not resolve " + artifact);
}
}
}
}
Expand Down Expand Up @@ -185,10 +187,12 @@ private void installAll(MavenPom pom, SimpleMavenRepository target) throws IOExc
}
}

// Try to install the dependency locally
if (!target.isInstalled(dependency) && !installArtifact(dependency, target) && dependencyPom == null) {
// The dependency had no artifact and also no POM
throw new MavenResolveException("Could not resolve " + dependency);
synchronized (target) {
// Try to install the dependency locally
if (!target.isInstalled(dependency) && !installArtifact(dependency, target) && dependencyPom == null) {
// The dependency had no artifact and also no POM
throw new MavenResolveException("Could not resolve " + dependency);
}
}
}
}
Expand Down

0 comments on commit e6fd978

Please sign in to comment.