clojure-android / lein-droid

A Leiningen plugin for building Clojure/Android projects
Eclipse Public License 1.0
645 stars 56 forks source link

Sanitize package name in main.clj #43

Closed oakes closed 11 years ago

oakes commented 11 years ago

I'm not sure if this is a recent thing or not, but with 0.2.0-SNAPSHOT, the app will fail at runtime if you put a hyphen in the package name:

lein droid new android-test com.android-test :target-sdk 15

This is because the package name is being sanitized in AndroidManifest.xml, but not in main.clj, so they are inconsistent. If you have a better solution, feel free to reject this PR.

alexander-yakushev commented 11 years ago

This is a problem, yes. Although I don't feel quite good about renaming people's namespaces. It is one thing when Clojure does it for naming compiled classes (which we don't use directly anyway) and the other thing when we rename something that was explicitly set.

I think the better solution to it would be to refuse creating a project with an offending package name. This will make a user manually change hyphens to underscores, or maybe rethink the name for the package. Either way, it will be less surprising and confusing.

Now, I cover only lein droid new task, so one will still be able to rename a project incorrectly after the creation. But placing a guard in every task seems to be an overkill. Perhaps adding a warning in the tutorial would be enough. What do you think?

oakes commented 11 years ago

Yeah a warning or error would make more sense now that I think of it.

alexander-yakushev commented 11 years ago

Good. The commit that introduced this is 60ed1a478ad15f5b5fa3e78f865b56f751d91dd5.