@Override @SuppressWarnings("unchecked") public T get() throws GradleConnectionException, IllegalStateException { Object cachedValue = this.cacheKey.isInvalid() ? null : this.cache.getIfPresent(this.cacheKey); if (cachedValue != null) { return (T) cachedValue; } else { T result = this.delegate.get(); this.cache.put(this.cacheKey, result); return result; } }
@Override public <T> T getModel(Class<T> modelType) throws GradleConnectionException, IllegalStateException { return model(modelType).get(); }
@Override public <T> void getModel(Class<T> modelType, ResultHandler<? super T> handler) throws IllegalStateException { model(modelType).get(handler); }
@Override public <T> void getModel(Class<T> modelType, ResultHandler<? super T> handler) throws IllegalStateException { model(modelType).get(handler); }
@Override public <T> T getModel(Class<T> modelType) throws GradleConnectionException, IllegalStateException { return model(modelType).get(); }
public <T> void getModel(final Class<T> modelType, final ResultHandler<? super T> handler) { model(modelType).get(handler); }
public <T> T getModel(Class<T> modelType) { return model(modelType).get(); }
/** * Returns a Gradle model of the project. * @param <T> the model type * @param modelType the model type * @return the model */ public <T> T get(Class<T> modelType) { return configure(connection.model(modelType)).get(); }
@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); } } });
@Override @SuppressWarnings("unchecked") public void get(ResultHandler<? super T> handler) throws IllegalStateException { Object cachedValue = this.cacheKey.isInvalid() ? null : this.cache.getIfPresent(this.cacheKey); if (cachedValue != null) { handler.onComplete((T) cachedValue); } else { InspectableResultHandler<T> inspectableResultHandler = new InspectableResultHandler<>(); this.delegate.get(inspectableResultHandler); inspectableResultHandler.getResult().ifPresent(r -> this.cache.put(this.cacheKey, r)); inspectableResultHandler.forwardResults(handler); } } }
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(); } }