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

draft create for Maven projects gets confused by the mvnw and mvnw.cmd files: "Draft detected the primary language as Shell..." #523

Open
cyrille-leclerc opened this issue Jan 31, 2018 · 5 comments

Comments

@cyrille-leclerc
Copy link
Contributor

cyrille-leclerc commented Jan 31, 2018

Problem Description

Java Maven projects using Takari's mvnw wrapper don't get properly discovered by draft create. They are seen as "Shell" applications.

Takari's mvnw wrapper is a very popular extension to Maven, it is included by default by Spring initializer (http://start.spring.io/) and by other leading Java project

$ draft create
--> Draft detected the primary language as Shell with 73.597919% certainty.
Error: Could not find a pack Q_Q

To reproduce

git clone https://github.com/Azure/draft.git
cd draft/examples/example-java
wget https://raw.githubusercontent.com/takari/maven-wrapper/maven-wrapper-0.3.0/mvnw
draft create

Error message

--> Draft detected the primary language as Shell with 73.597919% certainty.
Error: Could not find a pack Q_Q

Desired Message

--> Draft detected the primary language as Java with 92.205567% certainty.
--> Ready to sail

Workaround

Before running draft create, temporarily move mvnw and mvnw.cmdoutside of the project. Once draft create is successful, move mvnw and mvnw.cmd back in the project.

@cyrille-leclerc cyrille-leclerc changed the title draft create for Maven' mvnw draft create for Maven projects gets confused by the mvnw file: "Draft detected the primary language as Shell..." Jan 31, 2018
@cyrille-leclerc
Copy link
Contributor Author

Seem to be related to the file pkg/linguist/static.go that comes from https://github.com/github/linguist/blob/v6.0.1/lib/linguist/languages.yml

I'll try to declare mvnw next to the already declared gradlew.

https://github.com/github/linguist/blob/v6.0.1/lib/linguist/languages.yml#L4274

@cyrille-leclerc cyrille-leclerc changed the title draft create for Maven projects gets confused by the mvnw file: "Draft detected the primary language as Shell..." draft create for Maven projects gets confused by the mvnw and mvnw.cmd files: "Draft detected the primary language as Shell..." Jan 31, 2018
@bacongobbler
Copy link
Contributor

bacongobbler commented Feb 5, 2018

Given that mvnw is primarily written in bash, one could argue that linguist is "working as intended" in this case since it has not been trained against mvnw. In the meantime, you can override certain files using the .gitattributes file as per the troubleshooting documentation.

Specifically, this should work for your example:

$ cat .gitattributes
mvnw linguist-vendored

That way, mvnw is ignored as a vendored file. Moving to the future, you may want to look into adding mvnw as a vendored file at https://github.com/github/linguist/blob/master/lib/linguist/vendor.yml. That way users won't need to add this file to their .gitattributes file every time they wish to incorporate mvnw into their project.

Does that help clarify things?

@cyrille-leclerc
Copy link
Contributor Author

Thanks @bacongobbler . I'll try to get "mvnw" added to https://github.com/github/linguist/blob/master/lib/linguist/vendor.yml

@cyrille-leclerc
Copy link
Contributor Author

cyrille-leclerc commented Feb 19, 2018

FYI I have just submitted github-linguist/linguist#4042

@bacongobbler
Copy link
Contributor

Sounds good! Now that merge has made its way into linguist, it shouldn't be too hard to re-train our bayesian classifier based on that.

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

No branches or pull requests

2 participants