use of org.gradle.api.Project in project spring-security by spring-projects.
the class CheckAntoraVersionPluginTests method matchesWhenExplicitPrerelease.
@Test
void matchesWhenExplicitPrerelease() throws Exception {
Project project = ProjectBuilder.builder().build();
File rootDir = project.getRootDir();
IOUtils.write("version: '1.0.0'\nprerelease: '-SNAPSHOT'", new FileOutputStream(new File(rootDir, "antora.yml")), StandardCharsets.UTF_8);
project.getPluginManager().apply(CheckAntoraVersionPlugin.class);
Task task = project.getTasks().findByName(CheckAntoraVersionPlugin.ANTORA_CHECK_VERSION_TASK_NAME);
assertThat(task).isInstanceOf(CheckAntoraVersionTask.class);
CheckAntoraVersionTask checkAntoraVersionTask = (CheckAntoraVersionTask) task;
((CheckAntoraVersionTask) task).getAntoraVersion().set("1.0.0");
((CheckAntoraVersionTask) task).getAntoraPrerelease().set("-SNAPSHOT");
checkAntoraVersionTask.check();
}
use of org.gradle.api.Project in project atlas by alibaba.
the class AddLocalJarTask method run.
@TaskAction
void run() throws ExecutionException, InterruptedException, IOException, DocumentException {
ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(taskName, getLogger(), 0);
Project project = getProject();
// TODO localjar for main dex must on
for (AndroidLibrary androidLibrary : atlasDependencyTree.getMainBundle().getAllLibraryAars()) {
List<File> localJars = getLocalJars(androidLibrary.getFolder());
// System.out.println("get local libs");
for (File file : localJars) {
project.getLogger().info("add local jar to dependency " + file.getAbsolutePath() + "->" + androidLibrary.getResolvedCoordinates().toString());
}
androidLibrary.getLocalJars().addAll(localJars);
}
if (isLocalJarEnabled(project)) {
List<AndroidLibrary> bundleLibraries = new ArrayList<>(atlasDependencyTree.getAllAndroidLibrarys());
bundleLibraries.removeAll(atlasDependencyTree.getMainBundle().getAllLibraryAars());
for (final AndroidLibrary aarBundle : bundleLibraries) {
List<File> localJars = getLocalJars(aarBundle.getFolder());
// System.out.println("get local libs");
for (File file : localJars) {
project.getLogger().info("add local jar to dependency " + file.getAbsolutePath() + "->" + aarBundle.getResolvedCoordinates().toString());
}
aarBundle.getLocalJars().addAll(localJars);
}
}
}
use of org.gradle.api.Project in project atlas by alibaba.
the class AtlasListTask method executeTask.
@TaskAction
public void executeTask() {
Project project = getProject();
AtlasExtension atlasExtension = project.getExtensions().getByType(AtlasExtension.class);
List<AtlasConfigField> list = null;
try {
list = AtlasConfigHelper.readConfig(atlasExtension, "atlas");
} catch (Throwable e) {
e.printStackTrace();
return;
}
List<String> lines = new ArrayList<>();
lines.add(" function | The name of the configuration | type | value ");
lines.add(" ------------- | ------------- | ------------- | ------------- ");
for (AtlasConfigField configField : list) {
lines.add(configField.desc + " | " + configField.name + " | " + configField.type + " | " + configField.value);
}
for (String line : lines) {
project.getLogger().error(line);
}
File file = new File(project.getProjectDir(), "atlasConfigList.MD");
try {
FileUtils.writeLines(file, lines);
project.getLogger().error(file.getAbsolutePath() + " has generated");
} catch (IOException e) {
e.printStackTrace();
}
try {
FileUtils.write(new File(project.getProjectDir(), "atlasConfigList.json"), JSON.toJSONString(list, true));
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.gradle.api.Project in project atlas by alibaba.
the class AwbGenerator method createAwbBundle.
public AwbBundle createAwbBundle(LibVariantContext libVariantContext) throws IOException {
String variantName = libVariantContext.getVariantName();
AtlasDependencyTree libDependencyTree = AtlasBuildContext.libDependencyTrees.get(variantName);
// TODO 2.3
if (null == libDependencyTree) {
libDependencyTree = new AtlasDepTreeParser(libVariantContext.getProject(), new ExtraModelInfo(new ProjectOptions(libVariantContext.getProject()), null), new HashSet<>()).parseDependencyTree(libVariantContext.getVariantDependency());
AtlasBuildContext.libDependencyTrees.put(variantName, libDependencyTree);
}
Project project = libVariantContext.getProject();
String groupName = (String) project.getGroup();
String name = "";
String version = (String) project.getVersion();
if (project.hasProperty("archivesBaseName")) {
name = (String) project.getProperties().get("archivesBaseName");
} else {
name = project.getName();
}
File explodedDir = project.file(project.getBuildDir().getAbsolutePath() + "/" + FD_INTERMEDIATES + "/exploded-awb/" + computeArtifactPath(groupName, name, version));
FileUtils.deleteDirectory(explodedDir);
MavenCoordinates mavenCoordinates = new MavenCoordinatesImpl(groupName, name, version, "awb", "");
ResolvedDependencyInfo resolvedDependencyInfo = new ResolvedDependencyInfo(groupName, name, version, "awb");
resolvedDependencyInfo.setVariantName(libVariantContext.getVariantName());
AwbBundle awbBundle = new AwbBundle(resolvedDependencyInfo, DependencyConvertUtils.toAndroidLibrary(mavenCoordinates, libVariantContext.getBundleTask().getArchivePath(), explodedDir));
awbBundle.getSoLibraries().addAll(libDependencyTree.getMainBundle().getSoLibraries());
awbBundle.getAndroidLibraries().addAll(libDependencyTree.getMainBundle().getAndroidLibraries());
awbBundle.getJavaLibraries().addAll(libDependencyTree.getMainBundle().getJavaLibraries());
return awbBundle;
}
use of org.gradle.api.Project in project atlas by alibaba.
the class AwbGenerator method generateAwbArtifict.
/**
* Create a basic AWB task
*/
public void generateAwbArtifict(final Zip bundleTask, LibVariantContext libVariantOutputData) {
Project project = bundleTask.getProject();
bundleTask.setExtension("awb");
if (bundleTask instanceof AndroidZip) {
String fileName = FilenameUtils.getBaseName(bundleTask.getArchiveName()) + ".awb";
((AndroidZip) bundleTask).setArchiveNameSupplier(() -> fileName);
}
bundleTask.setDestinationDir(new File(bundleTask.getDestinationDir().getParentFile(), "awb"));
File destDir = libVariantOutputData.getScope().getBaseBundleDir();
bundleTask.doFirst(task -> {
File bundleBaseInfoFile = project.file("bundleBaseInfoFile.json");
File customBundleIdFile = project.file("customPackageID.txt");
if (bundleBaseInfoFile.exists()) {
project.getLogger().warn("copy " + bundleBaseInfoFile.getAbsolutePath() + " to awb");
try {
FileUtils.copyFileToDirectory(bundleBaseInfoFile, destDir);
} catch (IOException e) {
throw new GradleException(e.getMessage(), e);
}
}
if (customBundleIdFile.exists()) {
try {
FileUtils.copyFileToDirectory(customBundleIdFile, destDir);
} catch (IOException e) {
throw new GradleException(e.getMessage(), e);
}
}
});
bundleTask.doLast(task -> {
File outputFile = new File(bundleTask.getDestinationDir(), bundleTask.getArchiveName());
if (!outputFile.exists()) {
return;
}
// Regenerating aar
if (atlasExtension.getBundleConfig().isAwbBundle()) {
try {
FileUtils.copyFile(outputFile, new File(new File(bundleTask.getDestinationDir().getParentFile(), "aar"), FilenameUtils.getBaseName(bundleTask.getArchiveName()) + ".aar"));
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
Aggregations