Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Workaround for base-4.13.0.0 not on Hackage. Fix issue #511 and #514
Browse files Browse the repository at this point in the history
  • Loading branch information
rikvdkleij committed Mar 5, 2020
1 parent 152b147 commit e477f25
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Binary file added src/main/resources/lib/base-41300.zip
Binary file not shown.
21 changes: 18 additions & 3 deletions src/main/scala/intellij/haskell/module/HaskellModuleBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.intellij.openapi.ui.Messages
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.platform.templates.TemplateModuleBuilder
import com.intellij.platform.templates.github.ZipUtil
import icons.HaskellIcons
import intellij.haskell.cabal.CabalInfo
import intellij.haskell.external.component.{HaskellComponentsManager, PackageInfo}
Expand Down Expand Up @@ -293,7 +294,7 @@ object HaskellModuleBuilder {

val projectLibraryDependencies = dependenciesByModule.flatMap(_._3).distinct

downloadHaskellPackageSources(project, projectLibDirectory, stackPath, projectLibraryDependencies)
retrieveHaskellPackageSources(project, projectLibDirectory, stackPath, projectLibraryDependencies)

setupProjectLibraries(project, projectLibraryDependencies, projectLibDirectory)

Expand All @@ -304,12 +305,26 @@ object HaskellModuleBuilder {
}
}

private def downloadHaskellPackageSources(project: Project, projectLibDirectory: File, stackPath: String, libraryDependencies: Seq[HaskellLibraryDependency]): Unit = {
private final val Base_4_13_0_0_ZipName = "base-41300" // Exception while unzipping when name contains dots
private final val Base_4_13_0_0 = "base-4.13.0.0"

private def retrieveHaskellPackageSources(project: Project, projectLibDirectory: File, stackPath: String, libraryDependencies: Seq[HaskellLibraryDependency]): Unit = {
libraryDependencies.filterNot(libraryDependency => getPackageDirectory(projectLibDirectory, libraryDependency).exists()).foreach(libraryDependency => {
CommandLine.run1(project, projectLibDirectory.getAbsolutePath, stackPath, Seq("--no-nix", "unpack", libraryDependency.nameVersion), 10000)
if (libraryDependency.nameVersion == Base_4_13_0_0) {
val baseZip = new File(projectLibDirectory, Base_4_13_0_0_ZipName)
HaskellFileUtil.copyStreamToFile(getClass.getResourceAsStream(s"/lib/${Base_4_13_0_0_ZipName}.zip"), baseZip)
ZipUtil.unzip(null, projectLibDirectory, baseZip, null, null, false)
baseZip.delete()
} else {
downloadHaskellPackageSource(project, projectLibDirectory, stackPath, libraryDependency)
}
})
}

private def downloadHaskellPackageSource(project: Project, projectLibDirectory: File, stackPath: String, libraryDependency: HaskellLibraryDependency): Unit = {
CommandLine.run1(project, projectLibDirectory.getAbsolutePath, stackPath, Seq("--no-nix", "unpack", libraryDependency.nameVersion), 10000)
}

private def getPackageDirectory(projectLibDirectory: File, libraryDependency: HaskellLibraryDependency) = {
new File(projectLibDirectory, libraryDependency.nameVersion)
}
Expand Down

0 comments on commit e477f25

Please sign in to comment.