   catch
     :error, {:assembler, _mod, _reason} = err ->
       {:error, err}
+  end
+
+  # Finds sources for `app_name`. This is used for applications built from
+  # this project, where the source code lies in a different location than the
+  # compiled files.
+  defp project_app_src_dirs(app_name) do
+    case project_app_src_root(app_name) do
+      nil -> []
+      path -> Path.wildcard(Path.join(path, "{lib,src}"))
+    end
+  end
+
+  # Returns a path of the source code directory for an application built from
+  # this project.
+  defp project_app_src_root(app_name) do
+    if not Mix.Project.umbrella?() && Mix.Project.get().project[:app] == app_name do
+      # This is a top-level application.
+      File.cwd!()
+    else
+      # This returns a directory if the app is either a dependency or an
+      # application in umbrella. It returns `nil` otherwise.
+      Map.get(Mix.Project.deps_paths(), app_name)
+    end
   end
 
   # Creates release metadata files

            app_dir
          end

        copy_app(app_dir, target_dir, dev_mode?, include_src?)

      _ ->
        case Utils.is_erts_lib?(app_dir) do

              ["ebin", "include", "priv"]
          end

        extra_source_dirs = project_app_src_dirs(app_name)

        (Path.wildcard(Path.join(app_dir, "*")) ++ extra_source_dirs)
        |> Enum.filter(fn p -> Path.basename(p) in valid_dirs end)
        |> Enum.each(fn p ->
          t = Path.join(target_dir, Path.basename(p))
