vigneshsiva11 commented on issue #15575:
URL: https://github.com/apache/grails-core/issues/15575#issuecomment-4298261009

   Hi @jdaugherty! I found the problem. Here is what I think we should do:
   
   * The issue is that when a user sets GRAILS_REPO_URL to ~/.m2/repository the 
shell doesn't expand the ~ because it's stored as an environment variable.
   
   * When CreateAppCommand uses this value in the build.gradle template the ~ 
is taken literally. Gradle can't resolve it.
   
   To fix this we can change CreateAppCommand.groovy to normalize the path 
before putting it in the template. We can do this by replacing a leading ~ with 
the user's home directory.
   
   Here is how we can do it:
   
   ```groovy
   
   String repoUrl = System.getenv("GRAILS_REPO_URL")
   
   if (repoUrl != null && repoUrl.startsWith("~")) {
   
   String homeDir = System.getProperty("user.home")
   
   repoUrl = homeDir + repoUrl.substring(1)
   
   }
   
   ```
   
   This approach works on macOS, Linux, and Windows. It also doesn't rely on 
behavior. We should also add a test case to make sure it works.
   
   The test case will set GRAILS_REPO_URL to a path that starts with ~. Check 
that the generated build.gradle has a full path.
   
   I can make a request with this fix. Just let me know if this looks good or 
if you want me to change something.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to