Ejemplo n.º 1
0
 public File getFile() {
   if (file == null) {
     file = artifactSource.create();
     artifactSource = null;
   }
   return file;
 }
Ejemplo n.º 2
0
  public <T> T useCache(String operationDisplayName, Factory<? extends T> factory) {
    if (lockOptions != null && lockOptions.getMode() == FileLockManager.LockMode.Shared) {
      throw new UnsupportedOperationException("Not implemented yet.");
    }

    takeOwnership(operationDisplayName);
    boolean wasStarted = false;
    try {
      wasStarted = onStartWork();
      return factory.create();
    } finally {
      lock.lock();
      try {
        try {
          if (wasStarted) {
            onEndWork();
          }
        } finally {
          releaseOwnership();
        }
      } finally {
        lock.unlock();
      }
    }
  }
Ejemplo n.º 3
0
 public <T> T longRunningOperation(String operationDisplayName, Factory<? extends T> action) {
   boolean wasEnded = startLongRunningOperation(operationDisplayName);
   try {
     return action.create();
   } finally {
     finishLongRunningOperation(wasEnded);
   }
 }
Ejemplo n.º 4
0
 public static <T> T whileDisabled(Factory<T> factory) {
   ENABLED.set(false);
   try {
     return factory.create();
   } finally {
     ENABLED.set(true);
   }
 }
Ejemplo n.º 5
0
 protected MavenPublishAction createDeployTask(
     File pomFile,
     LocalMavenRepositoryLocator mavenRepositoryLocator,
     MavenArtifactRepository artifactRepository) {
   GradleWagonMavenDeployAction deployTask =
       new GradleWagonMavenDeployAction(pomFile, artifactRepository, repositoryTransportFactory);
   deployTask.setLocalMavenRepositoryLocation(temporaryDirFactory.create());
   deployTask.setRepositories(createMavenRemoteRepository(artifactRepository), null);
   return deployTask;
 }
Ejemplo n.º 6
0
 public void apply(Project project) {
   RepositoryHandler repositories =
       artifactPublicationServicesFactory.create().getRepositoryHandler();
   PublicationContainer publications =
       instantiator.newInstance(DefaultPublicationContainer.class, instantiator);
   project
       .getExtensions()
       .create(
           PublishingExtension.NAME, DefaultPublishingExtension.class, repositories, publications);
 }
 public void processTestClass(TestClassRunInfo testClass) {
   if (processor == null) {
     processor = factory.create();
     processor.startProcessing(resultProcessor);
   }
   processor.processTestClass(testClass);
   testCount++;
   if (testCount == restartEvery) {
     endBatch();
   }
 }
 private <T> T runWithOpenedCache(Factory<T> factory) {
   if (isOpen) {
     delegateCache.open();
     try {
       return factory.create();
     } finally {
       delegateCache.close();
     }
   } else {
     throw new CacheOpenException("Cannot run operation on cache that has not been opened.");
   }
 }
Ejemplo n.º 9
0
 private FileInfo copyIntoCache(
     Factory<File> baseDirFactory,
     File source,
     long lastModified,
     long length,
     HashValue hashValue) {
   File baseDir = baseDirFactory.create();
   File cachedFile = new File(baseDir, hashValue.asCompactString() + '/' + source.getName());
   if (!cachedFile.isFile()) {
     // Has previously been added to the cache directory
     GFileUtils.copyFile(source, cachedFile);
   }
   FileInfo fileInfo = new FileInfo(lastModified, length, hashValue, cachedFile);
   cachedFiles.put(source, fileInfo);
   return fileInfo;
 }
Ejemplo n.º 10
0
  RemoteTestClassProcessor forkProcess() {
    WorkerProcessBuilder builder = workerFactory.create();
    builder.setBaseName("Gradle Test Executor");
    builder.applicationClasspath(classPath);
    builder.setLoadApplicationInSystemClassLoader(true);
    builder.worker(new TestWorker(processorFactory));
    options.copyTo(builder.getJavaCommand());
    buildConfigAction.execute(builder);

    workerProcess = builder.build();
    workerProcess.start();

    ObjectConnection connection = workerProcess.getConnection();
    connection.useParameterSerializer(TestEventSerializer.create());
    connection.addIncoming(TestResultProcessor.class, resultProcessor);
    RemoteTestClassProcessor remoteProcessor =
        connection.addOutgoing(RemoteTestClassProcessor.class);
    connection.connect();
    remoteProcessor.startProcessing();
    return remoteProcessor;
  }
Ejemplo n.º 11
0
 public Class<? extends Plugin> resolve() {
   ClassPath classPath = classPathFactory.create();
   Factory<? extends ClassLoader> loader = parent.loader(classPath);
   PluginRegistry pluginRegistry = new DefaultPluginRegistry(loader, instantiator);
   return pluginRegistry.getTypeForId(pluginId.toString());
 }
Ejemplo n.º 12
0
 private File getTmpDir() {
   return tmpDirSource.create();
 }
Ejemplo n.º 13
0
 public <T> T readFile(Factory<? extends T> action)
     throws LockTimeoutException, FileIntegrityViolationException {
   assertOpenAndIntegral();
   return action.create();
 }
 public <T> T readFile(Factory<? extends T> action) throws LockTimeoutException {
   return action.create();
 }
 public <T> T longRunningOperation(String operationDisplayName, Factory<? extends T> action) {
   return action.create();
 }
 public <T> T useCache(String operationDisplayName, Factory<? extends T> action) {
   // The contract of useCache() means we have to provide some basic synchronization.
   synchronized (this) {
     return action.create();
   }
 }