@Override public CachingModelBuilder<T> withArguments(Iterable<String> arguments) { this.cacheKey.setArguments(arguments == null ? null : Lists.newArrayList(arguments)); this.delegate.withArguments(arguments); return this; }
@Override public CachingModelBuilder<T> withArguments(String... arguments) { this.cacheKey.setArguments(Arrays.asList(arguments)); this.delegate.withArguments(arguments); return this; }
@Override public PrideProjectModel execute(File moduleDirectory, ProjectConnection connection) { try { // Load the model for the build ModelBuilder<PrideProjectModel> builder = connection.model(PrideProjectModel.class); ImmutableList.Builder<String> arguments = ImmutableList.builder(); if (verbose) { arguments.add("--info", "--stacktrace"); } else { arguments.add("-q"); } // Add gradle-pride-projectmodel-plugin // See https://github.com/prezi/pride/issues/94 arguments.add("--init-script", modelInitFile.getAbsolutePath()); // See https://github.com/prezi/pride/issues/57 arguments.add("-P", "pride.disable"); //noinspection ToArrayCallWithZeroLengthArrayArgument builder.withArguments(arguments.build().toArray(new String[0])); return builder.get(); } catch (Exception ex) { String message = "Could not evaluate Gradle module in " + moduleDirectory + ": " + ex + "."; if (!verbose) { message += " You can get more detailed information about the error by rerunning Pride with --verbose."; } throw new PrideException(message, ex); } } });
static AndroidProject getAndroidProject( final File root, final org.gradle.tooling.model.GradleProject gradleProject) { String path = gradleProject.getPath(); String name = path.substring(1); File childDir = new File(root, name); GradleConnector childConnector = GradleConnector.newConnector().forProjectDirectory(childDir); ProjectConnection childConnection = childConnector.connect(); try { ModelBuilder<AndroidProject> modelBuilder = childConnection .model(AndroidProject.class) .withArguments("-Pandroid.injected.build.model.only.versioned=3"); if (nonNull(modelBuilder)) { return modelBuilder.get(); } return null; } catch (Exception e) { log.debug("not android project", e); return null; } finally { childConnection.close(); } }