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

codeArtifactPublish doesn't respect publishArtifact := false #23

Closed
akloss-cibo opened this issue Nov 29, 2023 · 2 comments · Fixed by #26
Closed

codeArtifactPublish doesn't respect publishArtifact := false #23

akloss-cibo opened this issue Nov 29, 2023 · 2 comments · Fixed by #26

Comments

@akloss-cibo
Copy link

When a project (or sub-project) has publishArtifact := false, codeArtifactPublish still attempts to publish artifacts, which fails like this:

sbt:jobs> codeArtifactPublish
[info] Uploading com/cibo/jobs_2.12/maven-metadata.xml
[error] stack trace is suppressed; run last codeArtifactPublish for the full output
[error] (codeArtifactPublish) Failed to publish to AWS Codeartifact. Errors:
[error] Code: 404, message: No package found with groupId: 'com.cibo' & artifactId: 'jobs_2.12'
[error] Total time: 1 s, completed Nov 28, 2023, 7:45:57 PM
sbt:jobs>

This seems pretty simple to fix:

diff --git a/sbt-codeartifact/src/main/scala/codeartifact/CodeArtifactPlugin.scala b/sbt-codeartifact/src/main/scala/codeartifact/CodeArtifactPlugin.scala
index 77bf616..9d0454c 100644
--- a/sbt-codeartifact/src/main/scala/codeartifact/CodeArtifactPlugin.scala
+++ b/sbt-codeartifact/src/main/scala/codeartifact/CodeArtifactPlugin.scala
@@ -60,10 +60,11 @@ object CodeArtifactPlugin extends AutoPlugin {
   // See: https://www.scala-sbt.org/1.x/docs/Howto-Dynamic-Task.html
   private def dynamicallyPublish: Def.Initialize[Task[Unit]] = Def.taskDyn {
     val shouldSkip = (publish / skip).value
+    val publishEnabled = (publish / publishArtifact).value
     val logger = streams.value.log
     val ref = thisProjectRef.value
 
-    if (shouldSkip) Def.task {
+    if (shouldSkip || !publishEnabled) Def.task {
       logger.debug(s"Skipping publish for ${ref.project}")
     }
     else publish0

Thoughts?

@scottynomad
Copy link

Makes sense to me!

@bbstilson
Copy link
Owner

Thanks for the report and the fix! Implemented here: #26

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants