Skip to content

Commit

Permalink
Allow the windows project name to be specified, fixes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Apr 26, 2017
1 parent ef3437c commit 1c5b81f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ public class BuildMojo extends AbstractMojo {
*/
private String windowsBuildTool;

/**
* The name of the msbuild/vcbuild project to use.
* Defaults to 'vs2010.vcxproj' for 'msbuild'
* and 'vs2008.vcproj' for 'vcbuild'.
*
* @parameter
*/
private String windowsProjectName;

private final CLI cli = new CLI();

public void execute() throws MojoExecutionException {
Expand Down Expand Up @@ -297,13 +306,13 @@ private void vsBasedBuild(File buildDir) throws CommandLineException, MojoExecut

if( useMSBuild ) {
// vcbuild was removed.. use the msbuild tool instead.
int rc = cli.system(buildDir, new String[]{"msbuild", "vs2010.vcxproj", "/property:Platform="+platform, "/property:Configuration="+configuration});
int rc = cli.system(buildDir, new String[]{"msbuild", windowsProjectName != null ? windowsProjectName : "vs2010.vcxproj", "/property:Platform="+platform, "/property:Configuration="+configuration});
if( rc != 0 ) {
throw new MojoExecutionException("vcbuild failed with exit code: "+rc);
}
} else {
// try to use a vcbuild..
int rc = cli.system(buildDir, new String[]{"vcbuild", "/platform:"+platform, "vs2008.vcproj", configuration});
int rc = cli.system(buildDir, new String[]{"vcbuild", "/platform:"+platform, windowsProjectName != null ? windowsProjectName : "vs2008.vcproj", configuration});
if( rc != 0 ) {
throw new MojoExecutionException("vcbuild failed with exit code: "+rc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ public class GenerateMojo extends AbstractMojo {
*/
private String windowsBuildTool;

/**
* The name of the msbuild/vcbuild project to use.
* Defaults to 'vs2010.vcxproj' for 'msbuild'
* and 'vs2008.vcproj' for 'vcbuild'.
*/
private String windowsProjectName;

private File targetSrcDir;

private CLI cli = new CLI();
Expand Down Expand Up @@ -244,9 +251,9 @@ private void generateBuildSystem() throws MojoExecutionException {
copyTemplateResource("vs2008.vcproj", true);
copyTemplateResource("vs2010.vcxproj", true);
} else if( "msbuild".equals(tool) ) {
copyTemplateResource("vs2010.vcxproj", true);
copyTemplateResource("vs2010.vcxproj", windowsProjectName != null ? windowsProjectName : "vs2010.vcxproj", true);
} else if( "vcbuild".equals(tool) ) {
copyTemplateResource("vs2008.vcproj", true);
copyTemplateResource("vs2008.vcproj", windowsProjectName != null ? windowsProjectName : "vs2008.vcproj", true);
} else if( "none".equals(tool) ) {
} else {
throw new MojoExecutionException("Invalid setting for windowsBuildTool: "+windowsBuildTool);
Expand Down Expand Up @@ -291,8 +298,12 @@ private ArrayList<String> getClasspath() throws MojoExecutionException {
}

private void copyTemplateResource(String file, boolean filter) throws MojoExecutionException {
copyTemplateResource(file, file, filter);
}

private void copyTemplateResource(String file, String output, boolean filter) throws MojoExecutionException {
try {
File target = FileUtils.resolveFile(packageDirectory, file);
File target = FileUtils.resolveFile(packageDirectory, output);
if( target.isFile() && target.canRead() ) {
return;
}
Expand Down

0 comments on commit 1c5b81f

Please sign in to comment.