swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.75k stars 1.35k forks source link

[SR-7596] Add new alias 'swift clean' that means 'swift package clean' #4819

Open alblue opened 6 years ago

alblue commented 6 years ago
Previous ID SR-7596
Radar None
Original Reporter @alblue
Type New Feature

Attachment: Download

Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Package Manager | |Labels | New Feature | |Assignee | None | |Priority | Medium | md5: 6aee4842767f1afbc8c6e5c52041ec60

Issue Description:

I have a custom bash script, called swift-clean, which just runs 'swift package clean'. It means that at the command line, I can do:

$ swift clean

in the same way that we do

$ swift build
$ swift test
$ swift run

Having a short cut would increase the utility of the functionality

aciidgh commented 6 years ago

Why do you need to clean? I think its important to fix the issues that forces people to clean rather than promoting clean operations.

aciidgh commented 6 years ago

Also, adding a top level command requires an evolution proposal.

alblue commented 6 years ago

At the moment, it's easier to do rm -rf .build, but this blows away the checkouts and caches. It would be fat better to run swift [package] clean, but that's more characters at the moment.

Also, if you consider the scope of other tools 'make clean; make test', 'go test', 'go clean', 'mvn clean', 'mvn compile' they all have a clean command. Even git has a clean command for removing detritus.

I don't think you need to try and justify it because 'you shouldn't need cleaning'. Every build system has it, and swift package manager surfaces it through swift package clean, so it should be a top level command like 'swift test', 'swift run' etc.

aciidgh commented 6 years ago

I am not sure if I agree with the philosophy of copying things from other build systems just because they have it. IMO the build system should be smart enough to take care of cleaning when required. Currently, cleaning is sometimes required for SwiftPM packages but those are open bugs. Two concrete examples:

LLBuild has a feature called "stale-file removal" which can solve the above two issues. I think we should try to understand why people are performing clean operations and try to solve those problems.

If you really think `swift clean` should be a top level command, please open a thread on Swift forums 🙂 .