Java Code Examples for org.gradle.api.model.ObjectFactory#property()

The following examples show how to use org.gradle.api.model.ObjectFactory#property() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitPublishPush.java    From gradle-git-publish with Apache License 2.0 6 votes vote down vote up
@Inject
public GitPublishPush(ObjectFactory objectFactory) {
  this.grgit = objectFactory.property(Grgit.class);
  this.branch = objectFactory.property(String.class);

  // always consider this task out of date
  this.getOutputs().upToDateWhen(t -> false);

  this.onlyIf(t -> {
    try {
      Grgit git = getGrgit().get();
      BranchStatus status = git.getBranch().status(op -> {
        op.setName(getBranch().get());
      });
      return status.getAheadCount() > 0;
    } catch (IllegalStateException e) {
      // if we're not tracking anything yet (i.e. orphan) we need to push
      return true;
    }
  });
}
 
Example 2
Source File: GenerateAvroJavaTask.java    From gradle-avro-plugin with Apache License 2.0 6 votes vote down vote up
@Inject
public GenerateAvroJavaTask(ObjectFactory objects) {
    super();
    this.outputCharacterEncoding = objects.property(String.class);
    this.stringType = objects.property(String.class).convention(DEFAULT_STRING_TYPE);
    this.fieldVisibility = objects.property(String.class).convention(DEFAULT_FIELD_VISIBILITY);
    this.templateDirectory = objects.property(String.class);
    this.createOptionalGetters = objects.property(Boolean.class).convention(DEFAULT_CREATE_OPTIONAL_GETTERS);
    this.gettersReturnOptional = objects.property(Boolean.class).convention(DEFAULT_GETTERS_RETURN_OPTIONAL);
    this.optionalGettersForNullableFieldsOnly = objects.property(Boolean.class)
        .convention(DEFAULT_OPTIONAL_GETTERS_FOR_NULLABLE_FIELDS_ONLY);
    this.createSetters = objects.property(Boolean.class).convention(DEFAULT_CREATE_SETTERS);
    this.enableDecimalLogicalType = objects.property(Boolean.class).convention(DEFAULT_ENABLE_DECIMAL_LOGICAL_TYPE);
    this.stringTypeProvider = getStringType()
        .map(input -> Enums.parseCaseInsensitive(OPTION_STRING_TYPE, StringType.values(), input));
    this.fieldVisibilityProvider = getFieldVisibility()
        .map(input -> Enums.parseCaseInsensitive(OPTION_FIELD_VISIBILITY, FieldVisibility.values(), input));
    this.logicalTypeFactories = objects.mapProperty(String.class, Constants.LOGICAL_TYPE_FACTORY_TYPE.getConcreteClass())
        .convention(DEFAULT_LOGICAL_TYPE_FACTORIES);
    this.customConversions = objects.listProperty(Constants.CONVERSION_TYPE.getConcreteClass()).convention(DEFAULT_CUSTOM_CONVERSIONS);
    this.resolver = new SchemaResolver(getProject(), getLogger());
}
 
Example 3
Source File: AutotoolsExtension.java    From native-samples with Apache License 2.0 5 votes vote down vote up
@Inject
public AutotoolsExtension(ObjectFactory objectFactory) {
    binary = objectFactory.property(String.class);
    includeDirectory = objectFactory.directoryProperty();
    sourceDirectory = objectFactory.directoryProperty();
    configureArguments = objectFactory.listProperty(String.class).empty();
    makeArguments = objectFactory.listProperty(String.class).empty();
}
 
Example 4
Source File: AspectJCompileOptions.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Inject
public AspectJCompileOptions(ObjectFactory objectFactory) {
    inpath = objectFactory.fileCollection();
    aspectpath = objectFactory.fileCollection();
    outjar = objectFactory.fileProperty();
    outxml = objectFactory.property(Boolean.class).convention(false);
    outxmlfile = objectFactory.property(String.class);
    sourceroots = objectFactory.fileCollection();
    crossrefs = objectFactory.property(Boolean.class).convention(false);
    bootclasspath = objectFactory.fileCollection();
    extdirs = objectFactory.fileCollection();
    encoding = objectFactory.property(String.class);
    verbose = objectFactory.property(Boolean.class).convention(false);
}
 
Example 5
Source File: DownloadWebDriver.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
@Inject
public DownloadWebDriver(WorkerExecutor workerExecutor) {
    this.workerExecutor = workerExecutor;
    ObjectFactory objects = getProject().getObjects();
    this.browser = objects.property(Browser.class);
    this.version = objects.property(String.class);
    this.os = objects.property(OS.class);
    this.arch = objects.property(Arch.class);
    this.outputFile = objects.fileProperty();
}
 
Example 6
Source File: AspectJCompileOptions.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Inject
public AspectJCompileOptions(ObjectFactory objectFactory) {
    inpath = objectFactory.fileCollection();
    aspectpath = objectFactory.fileCollection();
    outjar = objectFactory.fileProperty();
    outxml = objectFactory.property(Boolean.class).convention(false);
    outxmlfile = objectFactory.property(String.class);
    sourceroots = objectFactory.fileCollection();
    crossrefs = objectFactory.property(Boolean.class).convention(false);
    bootclasspath = objectFactory.fileCollection();
    extdirs = objectFactory.fileCollection();
    encoding = objectFactory.property(String.class);
    verbose = objectFactory.property(Boolean.class).convention(false);
}
 
Example 7
Source File: GitPublishReset.java    From gradle-git-publish with Apache License 2.0 5 votes vote down vote up
@Inject
public GitPublishReset(ProjectLayout layout, ObjectFactory objectFactory) {
  this.grgit = objectFactory.property(Grgit.class);
  this.repoDirectory = getProject().getObjects().directoryProperty();
  this.repoUri = objectFactory.property(String.class);
  this.referenceRepoUri = objectFactory.property(String.class);
  this.branch = objectFactory.property(String.class);

  // always consider this task out of date
  this.getOutputs().upToDateWhen(t -> false);
}
 
Example 8
Source File: AutotoolsExtension.java    From native-samples with Apache License 2.0 5 votes vote down vote up
@Inject
public AutotoolsExtension(ObjectFactory objectFactory) {
    binary = objectFactory.property(String.class);
    includeDirectory = objectFactory.directoryProperty();
    sourceDirectory = objectFactory.directoryProperty();
    configureArguments = objectFactory.listProperty(String.class).empty();
    makeArguments = objectFactory.listProperty(String.class).empty();
}
 
Example 9
Source File: CMakeExtension.java    From native-samples with Apache License 2.0 5 votes vote down vote up
@Inject
public CMakeExtension(ProjectLayout projectLayout, ObjectFactory objectFactory) {
    binary = objectFactory.property(String.class);
    includeDirectory = objectFactory.directoryProperty();
    projectDirectory = objectFactory.directoryProperty();
    projectDirectory.set(projectLayout.getProjectDirectory());
    includeDirectory.set(projectDirectory.dir("include"));
}
 
Example 10
Source File: CMakeExtension.java    From native-samples with Apache License 2.0 5 votes vote down vote up
@Inject
public CMakeExtension(ProjectLayout projectLayout, ObjectFactory objectFactory) {
    binary = objectFactory.property(String.class);
    includeDirectory = objectFactory.directoryProperty();
    projectDirectory = objectFactory.directoryProperty();
    projectDirectory.set(projectLayout.getProjectDirectory());
    includeDirectory.set(projectDirectory.dir("include"));
}
 
Example 11
Source File: GitPublishCommit.java    From gradle-git-publish with Apache License 2.0 5 votes vote down vote up
@Inject
public GitPublishCommit(ObjectFactory objectFactory) {
  this.grgit = objectFactory.property(Grgit.class);
  this.message = objectFactory.property(String.class);
  this.sign = objectFactory.property(Boolean.class);

  // always consider this task out of date
  this.getOutputs().upToDateWhen(t -> false);
}
 
Example 12
Source File: ContractVerifierExtension.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
@Inject
public Dependency(ObjectFactory objects) {
	groupId = objects.property(String.class);
	artifactId = objects.property(String.class);
	version = objects.property(String.class);
	classifier = objects.property(String.class);
	stringNotation = objects.property(String.class);
}
 
Example 13
Source File: CMakeExtension.java    From native-samples with Apache License 2.0 5 votes vote down vote up
@Inject
public CMakeExtension(ProjectLayout projectLayout, ObjectFactory objectFactory) {
    binary = objectFactory.property(String.class);
    includeDirectory = objectFactory.directoryProperty();
    projectDirectory = objectFactory.directoryProperty();
    projectDirectory.set(projectLayout.getProjectDirectory());
    includeDirectory.set(projectDirectory.dir("include"));
}
 
Example 14
Source File: GenerateProtoTask.java    From curiostack with MIT License 5 votes vote down vote up
@Inject
public GenerateProtoTask(
    String sourceSetName, ProtobufExtension config, WorkerExecutor workerExecutor) {
  this.sourceSetName = sourceSetName;
  this.workerExecutor = workerExecutor;

  execOverrides = new ArrayList<>();

  ObjectFactory objects = getProject().getObjects();

  sources = objects.sourceDirectorySet(sourceSetName, sourceSetName);
  sources.include("**/*.proto");
  includeDirs =
      objects.sourceDirectorySet(sourceSetName + "-includes", sourceSetName + "-includes");
  includeDirs.include("**/*.proto");
  protocPath = objects.property(File.class);
  protocArtifact = objects.property(String.class);
  outputBaseDir = objects.property(File.class);
  languages = objects.listProperty(LanguageSettings.class).empty();

  protocPath.set(config.getProtoc().getPath());
  protocArtifact.set(config.getProtoc().getArtifact());
  outputBaseDir.set(config.getOutputBaseDir());

  descriptorSetOptions = DescriptorSetOptions.create(objects);
  descriptorSetOptions.getEnabled().set(config.getDescriptorSetOptions().getEnabled());
  descriptorSetOptions.getPath().set(config.getDescriptorSetOptions().getPath());
  descriptorSetOptions
      .getIncludeSourceInfo()
      .set(config.getDescriptorSetOptions().getIncludeSourceInfo());
  descriptorSetOptions
      .getIncludeImports()
      .set(config.getDescriptorSetOptions().getIncludeImports());

  onlyIf(unused -> !sources.isEmpty());
}
 
Example 15
Source File: PlayExtension.java    From playframework with Apache License 2.0 5 votes vote down vote up
public PlayExtension(ObjectFactory objectFactory) {
    this.platform = objectFactory.newInstance(PlayPlatform.class, objectFactory);
    this.platform.getPlayVersion().convention(DEFAULT_PLAY_VERSION);
    this.platform.getJavaVersion().convention(JavaVersion.current());
    this.platform.getScalaVersion().convention(platform.getPlayVersion().map(playVersion -> PlayMajorVersion.forPlayVersion(playVersion).getDefaultScalaPlatform()));
    this.injectedRoutesGenerator = objectFactory.property(Boolean.class);
    injectedRoutesGenerator.convention(platform.getPlayVersion().map(playVersion -> !PlayMajorVersion.forPlayVersion(playVersion).hasSupportForStaticRoutesGenerator()));
}
 
Example 16
Source File: Jdk.java    From crate with Apache License 2.0 5 votes vote down vote up
Jdk(String name, Configuration configuration, ObjectFactory objectFactory) {
    this.name = name;
    this.configuration = configuration;
    this.vendor = objectFactory.property(String.class);
    this.version = objectFactory.property(String.class);
    this.arch = objectFactory.property(String.class);
    this.os = objectFactory.property(String.class);
}
 
Example 17
Source File: PlayRun.java    From playframework with Apache License 2.0 5 votes vote down vote up
public PlayRun() {
    ObjectFactory objects = getProject().getObjects();

    httpPort = objects.property(Integer.class).value(DEFAULT_HTTP_PORT);
    workingDir = objects.directoryProperty();
    applicationJar = objects.fileProperty();
    assetsJar = objects.fileProperty();
    assetsDirs = getProject().files();
    runtimeClasspath = getProject().files();
    changingClasspath = getProject().files();
    platform = objects.property(PlayPlatform.class);
    forkOptions = new BaseForkOptions();
}
 
Example 18
Source File: DefaultTwirlSourceSet.java    From playframework with Apache License 2.0 5 votes vote down vote up
@Inject
public DefaultTwirlSourceSet(String name, String displayName, ObjectFactory objectFactory) {
    twirl = objectFactory.sourceDirectorySet(name, displayName + " Twirl source");
    twirl.srcDirs("app");
    twirl.include("**/*.scala.*");
    defaultImports = objectFactory.property(TwirlImports.class);
    defaultImports.set(TwirlImports.SCALA);
    userTemplateFormats = objectFactory.listProperty(TwirlTemplateFormat.class).empty();
    additionalImports = objectFactory.listProperty(String.class).empty();
    constructorAnnotations = objectFactory.listProperty(String.class).empty();
}
 
Example 19
Source File: GithubExtension.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Inject
public GithubExtension(ObjectFactory objectFactory) {
    slug = objectFactory.property(String.class);

    username = objectFactory.property(String.class);
    token = objectFactory.property(String.class);

    tag = objectFactory.property(String.class).convention("HEAD");

    travis = objectFactory.property(Boolean.class);
}
 
Example 20
Source File: LinkTask.java    From skara with GNU General Public License v2.0 5 votes vote down vote up
@Inject
public LinkTask(ObjectFactory factory) {
    os = factory.property(String.class);
    cpu = factory.property(String.class);
    url = factory.property(String.class);
    toDir = factory.property(Path.class);
    launchers = factory.mapProperty(String.class, String.class);
    modules = factory.listProperty(String.class);
    modulePath = factory.setProperty(RegularFile.class);
    runtimeModules = factory.setProperty(FileSystemLocation.class);
}