Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ See the folder jmetemplate, fundamentally that is what ends up in the zip, but:
* E.g. [IF=JME_ANDROID]Android module :app : holds build.gradle for the android dependencies & implements the :game module, this module can hold android dependent gui.[/IF=JME_ANDROID]
* These can be nested, and can be multiline
* [DOT] is replaced by ".". This is supported because files starting with a . (like .gitignore) don't get into the jar, so don't get into the template
* [NOT=????] work exactly like [IF=????] but the inverted.

Additionally, optionally, you can end any file .jmetemplate. This has no actual function, but it is stripped from the
output file name. Its purpose is to stop IDEs from trying to do error highlighting on known file types (e.g. gradle files)
Expand Down
2 changes: 1 addition & 1 deletion libraries.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
{
"key": "TAMARIN",
"displayName": "Tamarin",
"category" : "GENERAL",
"category" : "HIDDEN",
"descriptionText" : "A virtual reality support library, providing VR hands & action based openVr",
"defaultSelected" : true,
"usesJmeVersion" : false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.jmonkeyengine.jmeinitializer;

import com.jmonkeyengine.jmeinitializer.libraries.JmePlatform;
import com.jmonkeyengine.jmeinitializer.libraries.Library;
import com.jmonkeyengine.jmeinitializer.libraries.LibraryCategory;
import com.jmonkeyengine.jmeinitializer.libraries.LibraryService;
Expand All @@ -22,6 +23,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -63,8 +65,9 @@ public InitializerZipService (VersionService versionService, LibraryService libr
}

public Map<String, String> produceGradleFilePreview(String gameName, String packageName, List<String> requiredLibraryKeys, List<String> deploymentOptionKeys ){
List<Library> requiredLibraries = eliminateLibrariesOnUnsupportedPlatforms(parseLibraryKeys(requiredLibraryKeys));
Merger merger = new Merger(gameName, packageName, requiredLibraries, calculateAdditionalProfiles(requiredLibraries, deploymentOptionKeys), versionService.getJmeVersion(), versionService.getVersionCache(), new FragmentFetcher() );
Collection<JmePlatform> requiredPlatforms = parsePlatforms(requiredLibraryKeys);
Collection<Library> requiredLibraries = eliminateLibrariesOnUnsupportedPlatforms(requiredPlatforms, parseLibraryKeys(requiredLibraryKeys));
Merger merger = new Merger(gameName, packageName, requiredPlatforms, requiredLibraries, calculateAdditionalProfiles(requiredLibraries, deploymentOptionKeys), versionService.getJmeVersion(), versionService.getVersionCache(), new FragmentFetcher() );

Map<String, String> gradleFiles = new HashMap<>();

Expand Down Expand Up @@ -112,9 +115,14 @@ public ByteArrayOutputStream produceZipInMemory(String gameName, String packageN
*/
public Map<String,byte[]> produceTemplate(String gameName, String packageName, List<String> requiredLibraryKeys, List<String> deploymentOptionKeys){

List<Library> requiredLibraries = eliminateLibrariesOnUnsupportedPlatforms(parseLibraryKeys(requiredLibraryKeys));
Collection<JmePlatform> requiredPlatforms = parsePlatforms(requiredLibraryKeys);
if(requiredPlatforms.isEmpty()){
throw new RuntimeException("No platforms were selected");
}

Collection<Library> requiredLibraries = eliminateLibrariesOnUnsupportedPlatforms(requiredPlatforms, parseLibraryKeys(requiredLibraryKeys));

Merger merger = new Merger(gameName, packageName, requiredLibraries, calculateAdditionalProfiles(requiredLibraries, deploymentOptionKeys), versionService.getJmeVersion(), versionService.getVersionCache(), new FragmentFetcher() );
Merger merger = new Merger(gameName, packageName, requiredPlatforms, requiredLibraries, calculateAdditionalProfiles(requiredLibraries, deploymentOptionKeys), versionService.getJmeVersion(), versionService.getVersionCache(), new FragmentFetcher() );

Map<String,byte[]> templateFiles = new HashMap<>();

Expand Down Expand Up @@ -167,29 +175,47 @@ public Map<String,byte[]> produceTemplate(String gameName, String packageName, L
return templateFiles;
}

private List<Library> parseLibraryKeys(List<String> requiredLibraryKeys){
private List<JmePlatform> parsePlatforms(List<String> requiredLibraryKeys) {
List<JmePlatform> platforms = new ArrayList<>();
for(String requiredLibraryKey : requiredLibraryKeys){
try {
platforms.add(JmePlatform.valueOf(requiredLibraryKey));
}catch(IllegalArgumentException e){
// this is fine, just a non-platform library
}
}
return platforms;
}

private Collection<Library> parseLibraryKeys(List<String> requiredLibraryKeys){
return requiredLibraryKeys
.stream()
.flatMap(lk -> libraryService.getLibraryFromKey(lk).stream())
.collect(Collectors.toList());
.collect(Collectors.toSet());
}

/**
* Given a raw list of libraries eliminates any who's required platform requirements aren't met
* @param unfilteredList
* @return
* @param requiredPlatforms the platforms that the user has requested
* @param unfilteredList the raw list of libraries
*/
private List<Library> eliminateLibrariesOnUnsupportedPlatforms(List<Library> unfilteredList){
List<Library> filtered = unfilteredList.stream()
private Collection<Library> eliminateLibrariesOnUnsupportedPlatforms(Collection<JmePlatform> requiredPlatforms, Collection<Library> unfilteredList){
Set<String> platformKeys = new HashSet<>();
for(JmePlatform platform : requiredPlatforms){
platformKeys.add(platform.name()); // what ideally the data would report as a required platform key
platformKeys.add(platform.getAlsoKnownAs()); // what the data actually reports as a required platform key
}

Collection<Library> filtered = unfilteredList.stream()
.filter(l -> {
if (l.getRequiredPlatforms().isEmpty()){
return true;
}else{
return unfilteredList.stream().anyMatch(matching -> l.getRequiredPlatforms().contains(matching.getKey()));
return platformKeys.stream().anyMatch(matching -> l.getRequiredPlatforms().contains(matching));
}

})
.collect(Collectors.toList());
.collect(Collectors.toSet());

if ( strictValidate && filtered.size() != unfilteredList.size()){
throw new RuntimeException("Illegal library requested and strictValidate is on");
Expand Down
26 changes: 19 additions & 7 deletions src/main/java/com/jmonkeyengine/jmeinitializer/MergeField.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,38 @@ public enum MergeField {
*/
DESKTOP_SPECIALISED_DEPENDENCIES,

/**
* This is everything that is not a jmonkey version library (it will include specialised libraries and probably
* should not be used on multi module projects
*/
ALL_NON_JME_DEPENDENCIES,

/**
* This is all non jmonkey libraries that are not specialised. I.e. in multimodule projects they go in the
* game module (not for example the android module).
*/
ALL_NON_JME_NON_SPECIALISED_DEPENDENCIES,

/**
* this is a series of variables for use in the toml file.
* <p>
* e.g.tamarin = "3.0.2"
* </p>
*/
ALL_NON_JME_VERSION_REFERENCES,

/**
* this is a series of variables for use in the toml file.
*
*/
ALL_NON_JME_TOML_LIBRARY_REFERENCES,

/**
* Maven repos required by the libraries. E.g. jcenter()
*
* This is a deduped list of all the libraries required by all the libraries
*/
MAVEN_REPOS,

CSV_LIBRARIES
/**
* Because tamarin is used in the templates itself it is handled seperately from the other non JME libraries
*/
TAMARIN_VERSION

;

/**
Expand Down
Loading