org.gradle.api.plugins.BasePluginConvention Java Examples

The following examples show how to use org.gradle.api.plugins.BasePluginConvention. 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: OsgiPluginConvention.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) {
    OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
    ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
    final OsgiHelper osgiHelper = new OsgiHelper();

    mapping.map("version", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getVersion(project.getVersion().toString());
        }
    });
    mapping.map("name", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
        }
    });
    mapping.map("symbolicName", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getBundleSymbolicName(project);
        }
    });

    return osgiManifest;
}
 
Example #2
Source File: OsgiPluginConvention.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) {
    OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
    ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
    final OsgiHelper osgiHelper = new OsgiHelper();

    mapping.map("version", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getVersion(project.getVersion().toString());
        }
    });
    mapping.map("name", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
        }
    });
    mapping.map("symbolicName", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getBundleSymbolicName(project);
        }
    });

    return osgiManifest;
}
 
Example #3
Source File: OsgiPluginConvention.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) {
    OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
    ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
    final OsgiHelper osgiHelper = new OsgiHelper();

    mapping.map("version", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getVersion(project.getVersion().toString());
        }
    });
    mapping.map("name", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
        }
    });
    mapping.map("symbolicName", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getBundleSymbolicName(project);
        }
    });

    return osgiManifest;
}
 
Example #4
Source File: OsgiPluginConvention.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private OsgiManifest createDefaultOsgiManifest(final ProjectInternal project) {
    OsgiManifest osgiManifest = project.getServices().get(Instantiator.class).newInstance(DefaultOsgiManifest.class, project.getFileResolver());
    ConventionMapping mapping = ((IConventionAware) osgiManifest).getConventionMapping();
    final OsgiHelper osgiHelper = new OsgiHelper();

    mapping.map("version", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getVersion(project.getVersion().toString());
        }
    });
    mapping.map("name", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
        }
    });
    mapping.map("symbolicName", new Callable<Object>() {
        public Object call() throws Exception {
            return osgiHelper.getBundleSymbolicName(project);
        }
    });

    return osgiManifest;
}
 
Example #5
Source File: PackageWebTask.java    From curiostack with MIT License 5 votes vote down vote up
@TaskAction
public void exec() throws IOException {
  Path packageJsonPath = getProject().file("build/web/package.json").toPath();
  String webPackageName = getWebPackageName().get();
  String packageName =
      webPackageName.isEmpty()
          ? getProject()
              .getConvention()
              .getPlugin(BasePluginConvention.class)
              .getArchivesBaseName()
          : webPackageName;

  Files.writeString(
      packageJsonPath,
      getPackageJsonTemplate()
          .get()
          .replaceFirst("\\|PACKAGE_NAME\\|", packageName)
          .replaceFirst("\\|TYPES_GOOGLE_PROTOBUF_VERSION\\|", TYPES_GOOGLE_PROTOBUF_VERSION)
          .replaceFirst("\\|GOOGLE_PROTOBUF_VERSION\\|", GOOGLE_PROTOBUF_VERSION)
          .replaceFirst("\\|GRPC_WEB_VERSION\\|", GRPC_WEB_VERSION)
          .replaceFirst(
              "\\|CURIOSTACK_BASE_NODE_DEV_VERSION\\|", CURIOSTACK_BASE_NODE_DEV_VERSION));

  getProject()
      .copy(
          copy -> {
            copy.from("build/webprotos");
            copy.into("build/web");
          });
}
 
Example #6
Source File: ProjectDependencyArtifactIdExtractorHack.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Nullable
private String getArchivesBaseName() {
    BasePluginConvention convention = project.getConvention().findPlugin(BasePluginConvention.class);
    return convention != null ? convention.getArchivesBaseName() : null;
}
 
Example #7
Source File: OsgiHelper.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Get the symbolic name as group + "." + archivesBaseName, with the following exceptions
 * <ul>
 * <li>
 * if group has only one section (no dots) and archivesBaseName is not null then the first package
 * name with classes is returned. eg. commons-logging:commons-logging -> org.apache.commons.logging
 * </li>
 * <li>
 * if archivesBaseName is equal to last section of group then group is returned.
 * eg. org.gradle:gradle -> org.gradle
 * </li>
 * <li>
 * if archivesBaseName starts with last section of group that portion is removed.
 * eg. org.gradle:gradle-core -> org.gradle.core
 * </li>
 * <li>
 * if archivesBaseName starts with the full group, the archivesBaseName is return,
 * e.g. org.gradle:org.gradle.core -> org.gradle.core
 * </li>
 * </ul>
 *
 * @param project The project being processed.
 *
 * @return Returns the SymbolicName that should be used for the bundle.
 */
public String getBundleSymbolicName(Project project) {
    String group = project.getGroup().toString();
    String archiveBaseName = project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
    if (archiveBaseName.startsWith(group)) {
        return archiveBaseName;
    }
    int i = group.lastIndexOf('.');
    String lastSection = group.substring(++i);
    if (archiveBaseName.equals(lastSection)) {
        return group;
    }
    if (archiveBaseName.startsWith(lastSection)) {
        String artifactId = archiveBaseName.substring(lastSection.length());
        if (Character.isLetterOrDigit(artifactId.charAt(0))) {
            return getBundleSymbolicName(group, artifactId);
        } else {
            return getBundleSymbolicName(group, artifactId.substring(1));
        }
    }
    return getBundleSymbolicName(group, archiveBaseName);
}
 
Example #8
Source File: ProjectDependencyArtifactIdExtractorHack.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Nullable
private String getArchivesBaseName() {
    BasePluginConvention convention = project.getConvention().findPlugin(BasePluginConvention.class);
    return convention != null ? convention.getArchivesBaseName() : null;
}
 
Example #9
Source File: OsgiHelper.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Get the symbolic name as group + "." + archivesBaseName, with the following exceptions
 * <ul>
 * <li>
 * if group has only one section (no dots) and archivesBaseName is not null then the first package
 * name with classes is returned. eg. commons-logging:commons-logging -> org.apache.commons.logging
 * </li>
 * <li>
 * if archivesBaseName is equal to last section of group then group is returned.
 * eg. org.gradle:gradle -> org.gradle
 * </li>
 * <li>
 * if archivesBaseName starts with last section of group that portion is removed.
 * eg. org.gradle:gradle-core -> org.gradle.core
 * </li>
 * <li>
 * if archivesBaseName starts with the full group, the archivesBaseName is return,
 * e.g. org.gradle:org.gradle.core -> org.gradle.core
 * </li>
 * </ul>
 *
 * @param project The project being processed.
 *
 * @return Returns the SymbolicName that should be used for the bundle.
 */
public String getBundleSymbolicName(Project project) {
    String group = project.getGroup().toString();
    String archiveBaseName = project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
    if (archiveBaseName.startsWith(group)) {
        return archiveBaseName;
    }
    int i = group.lastIndexOf('.');
    String lastSection = group.substring(++i);
    if (archiveBaseName.equals(lastSection)) {
        return group;
    }
    if (archiveBaseName.startsWith(lastSection)) {
        String artifactId = archiveBaseName.substring(lastSection.length());
        if (Character.isLetterOrDigit(artifactId.charAt(0))) {
            return getBundleSymbolicName(group, artifactId);
        } else {
            return getBundleSymbolicName(group, artifactId.substring(1));
        }
    }
    return getBundleSymbolicName(group, archiveBaseName);
}
 
Example #10
Source File: ProjectDependencyArtifactIdExtractorHack.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Nullable
private String getArchivesBaseName() {
    BasePluginConvention convention = project.getConvention().findPlugin(BasePluginConvention.class);
    return convention != null ? convention.getArchivesBaseName() : null;
}
 
Example #11
Source File: OsgiHelper.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Get the symbolic name as group + "." + archivesBaseName, with the following exceptions
 * <ul>
 * <li>
 * if group has only one section (no dots) and archivesBaseName is not null then the first package
 * name with classes is returned. eg. commons-logging:commons-logging -> org.apache.commons.logging
 * </li>
 * <li>
 * if archivesBaseName is equal to last section of group then group is returned.
 * eg. org.gradle:gradle -> org.gradle
 * </li>
 * <li>
 * if archivesBaseName starts with last section of group that portion is removed.
 * eg. org.gradle:gradle-core -> org.gradle.core
 * </li>
 * <li>
 * if archivesBaseName starts with the full group, the archivesBaseName is return,
 * e.g. org.gradle:org.gradle.core -> org.gradle.core
 * </li>
 * </ul>
 *
 * @param project The project being processed.
 *
 * @return Returns the SymbolicName that should be used for the bundle.
 */
public String getBundleSymbolicName(Project project) {
    String group = project.getGroup().toString();
    String archiveBaseName = project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
    if (archiveBaseName.startsWith(group)) {
        return archiveBaseName;
    }
    int i = group.lastIndexOf('.');
    String lastSection = group.substring(++i);
    if (archiveBaseName.equals(lastSection)) {
        return group;
    }
    if (archiveBaseName.startsWith(lastSection)) {
        String artifactId = archiveBaseName.substring(lastSection.length());
        if (Character.isLetterOrDigit(artifactId.charAt(0))) {
            return getBundleSymbolicName(group, artifactId);
        } else {
            return getBundleSymbolicName(group, artifactId.substring(1));
        }
    }
    return getBundleSymbolicName(group, archiveBaseName);
}
 
Example #12
Source File: ProjectDependencyArtifactIdExtractorHack.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Nullable
private String getArchivesBaseName() {
    BasePluginConvention convention = project.getConvention().findPlugin(BasePluginConvention.class);
    return convention != null ? convention.getArchivesBaseName() : null;
}
 
Example #13
Source File: OsgiHelper.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Get the symbolic name as group + "." + archivesBaseName, with the following exceptions
 * <ul>
 * <li>
 * if group has only one section (no dots) and archivesBaseName is not null then the first package
 * name with classes is returned. eg. commons-logging:commons-logging -> org.apache.commons.logging
 * </li>
 * <li>
 * if archivesBaseName is equal to last section of group then group is returned.
 * eg. org.gradle:gradle -> org.gradle
 * </li>
 * <li>
 * if archivesBaseName starts with last section of group that portion is removed.
 * eg. org.gradle:gradle-core -> org.gradle.core
 * </li>
 * <li>
 * if archivesBaseName starts with the full group, the archivesBaseName is return,
 * e.g. org.gradle:org.gradle.core -> org.gradle.core
 * </li>
 * </ul>
 *
 * @param project The project being processed.
 *
 * @return Returns the SymbolicName that should be used for the bundle.
 */
public String getBundleSymbolicName(Project project) {
    String group = project.getGroup().toString();
    String archiveBaseName = project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName();
    if (archiveBaseName.startsWith(group)) {
        return archiveBaseName;
    }
    int i = group.lastIndexOf('.');
    String lastSection = group.substring(++i);
    if (archiveBaseName.equals(lastSection)) {
        return group;
    }
    if (archiveBaseName.startsWith(lastSection)) {
        String artifactId = archiveBaseName.substring(lastSection.length());
        if (Character.isLetterOrDigit(artifactId.charAt(0))) {
            return getBundleSymbolicName(group, artifactId);
        } else {
            return getBundleSymbolicName(group, artifactId.substring(1));
        }
    }
    return getBundleSymbolicName(group, archiveBaseName);
}