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

Upgrade to SBT 1.5 #42

Merged
merged 23 commits into from
Sep 9, 2021
Merged

Upgrade to SBT 1.5 #42

merged 23 commits into from
Sep 9, 2021

Conversation

sbly
Copy link
Contributor

@sbly sbly commented Aug 11, 2021

No description provided.

@SethTisue
Copy link
Member

Was it hard keeping sbt 0.13 support? (Because I don't think it's really necessary to keep sbt 0.13 in the crossbuild.)

@sbly
Copy link
Contributor Author

sbly commented Aug 12, 2021

@SethTisue Uh whoops, I forgot about that, sorry! I was only testing 1.5.5. I can fix it to work with both versions, but it would easier if we just remove it, so I'll do that if you're OK with it

@SethTisue
Copy link
Member

SethTisue commented Aug 12, 2021

Yes, definitely okay. We don't have surplus of maintenance energy in this repo, so I think it's good to prioritize level-of-maintenance-effort over supporting people using ancient versions of things. (And sbt 0.13 is really ancient at this point; I'm encouraging basically all sbt plugin authors to stop supporting it. If there's somebody who's truly stuck on sbt 0.13 and absolutely needs to make changes to this plugin, they're welcome to fork the repo and do the maintenance and publishing work themselves.)

@SethTisue SethTisue closed this Aug 12, 2021
@SethTisue SethTisue reopened this Aug 12, 2021
@SethTisue
Copy link
Member

SethTisue commented Aug 12, 2021

I hit the "migrate" button over at travis-ci.com to get CI going again. (And close/reopen to kick it off.)

@sbly
Copy link
Contributor Author

sbly commented Aug 12, 2021

@SethTisue Thanks, I'll remove it!

It looks like we do have Travis CI. Did you want to migrate to Github actions?

@SethTisue
Copy link
Member

Staying on Travis CI is fine, but moving to GitHub Actions is fine too, if somebody wants to tackle that.

@sbly
Copy link
Contributor Author

sbly commented Aug 13, 2021

@SethTisue Gotcha. It looks like it's passing. Can we merge this for now? And then cut a new release?

@SethTisue
Copy link
Member

SethTisue commented Aug 13, 2021

@pvlugter @mpollmeier are you guys still interested in this plugin? I can temporarily step in from time to time in sbt/* repos, but there are so many such repos that there's a danger of it eating too much of my time

@mpollmeier
Copy link
Contributor

Hmm, we do use this plugin (ancient version still works fine). I don't have enough free cycles to actively maintain this repo, but helping out here and there (if it's within my area of knowledge) may work. Not sure if that's what you were after?

@pvlugter
Copy link
Member

We haven't used this plugin at Lightbend for a long time now. Would be useful to have the releasing updated to be an automated publish on tags, so that it's easy for any active maintainers to review and release changes.

Comment on lines 45 to 48
proguardInputs := {
assembly.value
Seq((assembly / assemblyOutputPath).value)
},
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for depending on sbt-assembly and always going through an assembly first? Just using the classpath seems like a simpler default, and pre-assembly can be added when needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't get it to work by using the classpath. My understanding (correct me if i'm wrong) is that Proguard can only work on fat jars. But maybe I was doing something wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just tried it again and it's still running into errors. It's possible that the task keys this was using before have changed between versions

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Since there are other changes, both inputs and libraries, could be good to confirm what's going on here. It should certainly work as before, with a classpath of inputs rather than a fat jar.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm really not a proguard expert but would also think that sbt-assembly shouldn't be mandated.
It wouldn't be the end of the world and if there's no other way I'd rather merge this PR.

However: I just tried your branch and reverted to the old proguardInputs := (fullClasspath in Runtime).value.files and removed all sbt-assembly related settings/dependency declarations. The included test projects work just fine (two of which do not use sbt-assembly themselves), and so does our internal build (which uses sbt-native-packager).

Can you clarify what kind of errors you're running into? Maybe those are actually unrelated to assembly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's odd. None of the tests work for me when I try that. This is the error I get:

[info] [info] Proguard command:
[info] [info] java -Xmx256M -cp /Users/sbly/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/guardsquare/proguard-base/7.0.0/proguard-base-7.0.0.jar:/Users/sbly/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/guardsquare/proguard-core/7.0.0/proguard-core-7.0.0.jar:/Users/sbly/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar:/Users/sbly/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.3.31/kotlin-stdlib-1.3.31.jar:/Users/sbly/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.31/kotlin-stdlib-common-1.3.31.jar:/Users/sbly/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-metadata-jvm/0.1.0/kotlinx-metadata-jvm-0.1.0.jar:/Users/sbly/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/annotations/13.0/annotations-13.0.jar proguard.ProGuard -injars "/private/var/folders/34/jl47bvtd2_14y99v6gx4k0bm0000gt/T/sbt_d73d4659/target/scala-2.12/classes" -injars "/Users/sbly/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.3/scala-library-2.12.3.jar" -libraryjars "/Users/sbly/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.3/scala-library-2.12.3.jar" -libraryjars "/Users/sbly/Library/Java/JavaVirtualMachines/corretto-11.0.12/Contents/Home" -outjars "/private/var/folders/34/jl47bvtd2_14y99v6gx4k0bm0000gt/T/sbt_d73d4659/target/scala-2.12/proguard/simple_2.12-0.1.0-SNAPSHOT.jar" -dontoptimize -dontnote -dontwarn -ignorewarnings -keep public class Test {
[info] [info]     public static void main(java.lang.String[]);
[info] [info] }
[info] [info] ProGuard, version 7.0.0
[info] [error] Error: The same input jar [/Users/sbly/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.3/scala-library-2.12.3.jar] is specified twice.
[info] [error] java.lang.RuntimeException: Proguard failed with exit code [1]

Depending on what other settings I tweak, I encounter other errors, but I can never get it working without assembly. If you can, that's great. Maybe my local setup is somehow broken

Copy link
Contributor

Choose a reason for hiding this comment

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

update: we removed sbt-assembly for the final version of this PR

@sbly
Copy link
Contributor Author

sbly commented Aug 18, 2021

@SethTisue Hey, is it possible to merge this, or did you want to hold off?

@SethTisue
Copy link
Member

SethTisue commented Aug 18, 2021

@mpollmeier do you have an opinion about the concern Peter raised about adding the dependency on sbt-assembly?

I have never used this plugin myself (though I used to be a heavy user of ProGuard itself, back in applet days 🙀), so I don't know how much my opinion is worth, but I share Peter's concern that it seems like a pretty big change, and we don't know if users are depending on the old behavior.

My understanding (correct me if i'm wrong) is that Proguard can only work on fat jars

I really doubt that's the case. At https://github.com/Guardsquare/proguard/blob/master/docs/md/manual/refcard.md we see -libraryjars .

Copy link
Member

@pvlugter pvlugter left a comment

Choose a reason for hiding this comment

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

With this building against sbt 1.5, it may not work with earlier sbt 1.x versions. Do we want to support all 1.x versions? Something we've done for other plugins is build against a 1.0 version, and rely on compatibility, with scripted tests for later sbt versions.

Comment on lines 37 to 44
proguardBinaryDeps := {
(Compile / libraryDependencies).value match {
case analysis: Analysis =>
analysis.relations.allLibraryDeps.collect { case vf: PathBasedFile =>
vf.toPath.toFile
}.toSeq
}
},
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this is no longer used.

Previously, the binary deps were pulled from the compile analysis to include all binaries, including Java's rt.jar. Looks like that's no longer included under library deps, and I see there's a java home added instead.

Would be good to make sure there's still something that works here across Java versions and environments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, using this method the Java libraries were missing, which is why I added an explicit dependency on JAVA_HOME

src/main/scala/com/typesafe/sbt/SbtProguard.scala Outdated Show resolved Hide resolved
@SethTisue
Copy link
Member

SethTisue commented Aug 19, 2021

With this building against sbt 1.5, it may not work with earlier sbt 1.x versions.

Ah, so, this is a subject I have opinions on... here they come :-)

Do we want to support all 1.x versions?

In short, no. People should upgrade to latest sbt if they want to use latest plugin versions. That's the decision I'm seeing most sbt plugin maintainers make.

I think it can definitely make sense in a commercial-support context to go the extra mile to ensure compatibility with old versions of things, but here in pure OSS-land where no money is changing hands (even though lots of people are making money using free stuff) and maintainer and contributor effort is the scarcest and most precious resource, I think the onus should be on users to put in a little effort and upgrade things if they want to benefit from the latest free OSS goodies — rather than the onus being on maintainers to accommodate version laggards. (I don't mean "laggards" as shade; people often have good reasons for being conservative about upgrades, but regardless, they should expect a decision not to upgrade to have consequences.)

Also, I'd add that the latest really disruptive change (though overall a hugely beneficial one) made to sbt was the Ivy->Coursier switch. That was a while ago now (sbt 1.4.0, May 2019). Once people are over the 1.4.0 hump — and they've now had plenty of time to get over it — it's only rarely a problem to go all the way to 1.5.5.

@sbly
Copy link
Contributor Author

sbly commented Aug 19, 2021

I am going to give it another shot without using assembly. Maybe I was just doing something wrong

@sbly
Copy link
Contributor Author

sbly commented Aug 19, 2021

I'm absolutely stuck on getting this to work. I can't figure it out. So we can close this PR if we don't want to bring in assembly and no one else wants to work on it

@mpollmeier
Copy link
Contributor

My comment above #42 (comment) is easily missed in the noise, so linking here again.

I think we can just take out the sbt-assembly related additions and merge the remainder as is. The test projects in this repo (as well as our internal build) work just fine.

And separately from that we can try to help @sbly to solve his specific issue. If it turns out to be a genuine issue and we really do need sbt-assembly, it wouldn't be the end of the world either, but currently I don't see why we should.

@mpollmeier
Copy link
Contributor

I forked this PR and pushed a few fixes. It's now not using sbt-assembly and filters out the duplicate input jars.
https://github.com/mpollmeier/sbt-proguard/tree/sbt-1.5

Could you please give that a try? If it works you could push those commits to this PR and we can merge it.

For reference: here's how I tested locally, not sure if that's the best way, but worked for me:

sbt 'clean; set version := "0.5.0+1-noassembly"; publishLocal'

cd src/sbt-test/proguard/<simple|merge|filter>
sbt -J-Dproject.version=0.5.0+1-noassembly proguard

@sbly
Copy link
Contributor Author

sbly commented Aug 31, 2021

Thanks for taking a stab at this. I cloned your repo and ran sbt scripted proguard/simple, which is how I've been testing. I got similar errors to what I had before. Does it work for you?

@mpollmeier
Copy link
Contributor

I only just learned about sbt-test and made myself familiar (https://www.scala-sbt.org/1.x/docs/Testing-sbt-plugins.html).

And yes, I'm also getting an error there, but that's a different one now: Error: Invalid or corrupt jarfile - is that what you're getting?

It's because simple/test.sbt is running java -jar on the jar that proguard produces, and that doesn't have a MANIFEST.MF.
I didn't manage to configure proguard to keep the correct manifest unfortunately - do you have any ideas?

@sbly
Copy link
Contributor Author

sbly commented Sep 1, 2021

@mpollmeier OK cool, so it's not just my machine. I've gotten that specific error before too. I was able to get rid of it before by changing the default input filter:

proguardDefaultInputFilter := None

but then I just ran into another error.

@mpollmeier
Copy link
Contributor

Ok I finally managed to sort this out, mostly by reverting some of the changes in this PR that were unrelated to the sbt upgrade.
Most importantly for fixing the MANIFEST issue above was the fact that you changed the proguard config for the simple test build.

I'm not saying that this is the best default value, but would suggest to focus this PR on purely upgrading sbt:
https://github.com/mpollmeier/sbt-proguard/tree/sbt-1.5

sbt scripted works with that.
@sbly Could you please give that a try? If it works you could push those commits to this PR and we can merge it.

@sbly
Copy link
Contributor Author

sbly commented Sep 8, 2021

@mpollmeier Thank you so much. Do you know what the actual fix was? It seems to have just been a problem with the test itself

@mpollmeier
Copy link
Contributor

The main differences to the initial PR were to remove sbt-assembly and get the test setup back to what it was - you removed some proguard settings in that simple test, which made it drop it's manifest.md.

@SethTisue @pvlugter 🙏🏻 I believe this is ready for merge/release - would you mind clicking a few buttons?

Copy link
Member

@SethTisue SethTisue left a comment

Choose a reason for hiding this comment

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

I've made one (admittedly a bit nitpicky) change request, otherwise LGTM for merge.

src/sbt-test/proguard/filter/build.sbt Outdated Show resolved Hide resolved
This was referenced Sep 9, 2021
@SethTisue SethTisue merged commit 579dac3 into sbt:master Sep 9, 2021
@SethTisue
Copy link
Member

thank you @sbly and @mpollmeier !!

ticket on actually getting this published: #43

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

Successfully merging this pull request may close these issues.

4 participants