Skip to content

Commit

Permalink
playframework#1142 add parameter --shortModuleNames to play deps
Browse files Browse the repository at this point in the history
…command

it creates modules directories without version numbers
  • Loading branch information
asolntsev committed May 17, 2017
1 parent 91f5208 commit e6abd14
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
8 changes: 7 additions & 1 deletion framework/pym/play/commands/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def execute(**kargs):

force = "false"
trim = "false"
shortModuleNames = "false"

if args.count('--forceCopy') == 1:
args.remove('--forceCopy')
force = "true"
Expand All @@ -29,11 +31,15 @@ def execute(**kargs):
force = "true"
trim = "true"

if args.count('--shortModuleNames') == 1:
args.remove('--shortModuleNames')
shortModuleNames = "true"

classpath = app.getClasspath()
args_memory = app.java_args_memory(args)
app.jpda_port = app.readConf('jpda.port')

add_options = ['-Dapplication.path=%s' % (app.path), '-Dframework.path=%s' % (play_env['basedir']), '-Dplay.id=%s' % play_env['id'], '-Dplay.version=%s' % play_env['version'], '-Dplay.forcedeps=%s' % (force), '-Dplay.trimdeps=%s' % (trim)]
add_options = ['-Dapplication.path=%s' % (app.path), '-Dframework.path=%s' % (play_env['basedir']), '-Dplay.id=%s' % play_env['id'], '-Dplay.version=%s' % play_env['version'], '-Dplay.forcedeps=%s' % (force), '-Dplay.trimdeps=%s' % (trim), '-Dplay.shortModuleNames=%s' % (shortModuleNames)]
if args.count('--verbose'):
args.remove('--verbose')
add_options.append('-Dverbose')
Expand Down
23 changes: 17 additions & 6 deletions framework/src/play/deps/DependenciesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,10 @@ public List<File> retrieve(ResolveReport report) throws Exception {
}

public File install(ArtifactDownloadReport artifact) throws Exception {
Boolean force = "true".equalsIgnoreCase(System.getProperty("play.forcedeps"));
Boolean trim = "true".equalsIgnoreCase(System.getProperty("play.trimdeps"));
boolean force = "true".equalsIgnoreCase(System.getProperty("play.forcedeps"));
boolean trim = "true".equalsIgnoreCase(System.getProperty("play.trimdeps"));
boolean shortModuleNames = "true".equalsIgnoreCase(System.getProperty("play.shortModuleNames"));

try {
File from = artifact.getLocalFile();

Expand All @@ -298,10 +300,7 @@ public File install(ArtifactDownloadReport artifact) throws Exception {

} else {
// A module
String mName = from.getName();
if (mName.endsWith(".jar") || mName.endsWith(".zip")) {
mName = mName.substring(0, mName.length() - 4);
}
String mName = moduleName(artifact, shortModuleNames);
File to = new File(application, "modules" + File.separator + mName).getCanonicalFile();
new File(application, "modules").mkdir();
Files.delete(to);
Expand Down Expand Up @@ -331,6 +330,18 @@ public File install(ArtifactDownloadReport artifact) throws Exception {
}
}

private String moduleName(ArtifactDownloadReport artifact, boolean shortModuleNames) {
if (shortModuleNames) {
return artifact.getName();
}

String mName = artifact.getLocalFile().getName();
if (mName.endsWith(".jar") || mName.endsWith(".zip")) {
mName = mName.substring(0, mName.length() - 4);
}
return mName;
}

private boolean isFrameworkLocal(ArtifactDownloadReport artifact) throws Exception {
String artifactFileName = artifact.getLocalFile().getName();
return new File(framework, "framework/lib/" + artifactFileName).exists()
Expand Down

0 comments on commit e6abd14

Please sign in to comment.