use of org.gradle.internal.jvm.JavaModuleDetector in project gradle by gradle.
the class CreateStartScripts method generate.
@TaskAction
public void generate() {
StartScriptGenerator generator = new StartScriptGenerator(unixStartScriptGenerator, windowsStartScriptGenerator);
JavaModuleDetector javaModuleDetector = getJavaModuleDetector();
generator.setApplicationName(getApplicationName());
generator.setMainClassName(fullMainArgument());
generator.setDefaultJvmOpts(getDefaultJvmOpts());
generator.setOptsEnvironmentVar(getOptsEnvironmentVar());
generator.setExitEnvironmentVar(getExitEnvironmentVar());
generator.setClasspath(getRelativePath(javaModuleDetector.inferClasspath(mainModule.isPresent(), getClasspath())));
generator.setModulePath(getRelativePath(javaModuleDetector.inferModulePath(mainModule.isPresent(), getClasspath())));
if (StringUtils.isEmpty(getExecutableDir())) {
generator.setScriptRelPath(getUnixScript().getName());
} else {
generator.setScriptRelPath(getExecutableDir() + "/" + getUnixScript().getName());
}
generator.generateUnixScript(getUnixScript());
generator.generateWindowsScript(getWindowsScript());
}
use of org.gradle.internal.jvm.JavaModuleDetector in project gradle by gradle.
the class IdeaDependenciesProvider method visitDependencies.
private IdeaDependenciesVisitor visitDependencies(IdeaModule ideaModule, GeneratedIdeaScope scope) {
ProjectInternal projectInternal = (ProjectInternal) ideaModule.getProject();
final DependencyHandler handler = projectInternal.getDependencies();
final Collection<Configuration> plusConfigurations = getPlusConfigurations(ideaModule, scope);
final Collection<Configuration> minusConfigurations = getMinusConfigurations(ideaModule, scope);
final JavaModuleDetector javaModuleDetector = projectInternal.getServices().get(JavaModuleDetector.class);
final IdeaDependenciesVisitor visitor = new IdeaDependenciesVisitor(ideaModule, scope.name());
return projectInternal.getOwner().fromMutableState(p -> {
new IdeDependencySet(handler, javaModuleDetector, plusConfigurations, minusConfigurations, false, gradleApiSourcesResolver).visit(visitor);
return visitor;
});
}
use of org.gradle.internal.jvm.JavaModuleDetector in project gradle by gradle.
the class Javadoc method generate.
@TaskAction
protected void generate() {
File destinationDir = getDestinationDir();
try {
getDeleter().ensureEmptyDirectory(destinationDir);
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
StandardJavadocDocletOptions options = new StandardJavadocDocletOptions((StandardJavadocDocletOptions) getOptions());
if (options.getDestinationDirectory() == null) {
options.destinationDirectory(destinationDir);
}
boolean isModule = isModule();
JavaModuleDetector javaModuleDetector = getJavaModuleDetector();
options.classpath(new ArrayList<>(javaModuleDetector.inferClasspath(isModule, getClasspath()).getFiles()));
options.modulePath(new ArrayList<>(javaModuleDetector.inferModulePath(isModule, getClasspath()).getFiles()));
if (options.getBootClasspath() != null && !options.getBootClasspath().isEmpty()) {
// Added so JavaDoc has the same behavior as JavaCompile regarding the bootClasspath
getProjectLayout().files(options.getBootClasspath()).getAsPath();
}
// See #19726 for more
if (isModule) {
List<File> sourceDirectories = getSource().getFiles().stream().map(File::getParentFile).distinct().sorted().collect(Collectors.toList());
options.setSourcePath(sourceDirectories);
}
if (!isTrue(options.getWindowTitle()) && isTrue(getTitle())) {
options.windowTitle(getTitle());
}
if (!isTrue(options.getDocTitle()) && isTrue(getTitle())) {
options.setDocTitle(getTitle());
}
String maxMemory = getMaxMemory();
if (maxMemory != null) {
final List<String> jFlags = options.getJFlags();
final Iterator<String> jFlagsIt = jFlags.iterator();
boolean containsXmx = false;
while (!containsXmx && jFlagsIt.hasNext()) {
final String jFlag = jFlagsIt.next();
if (jFlag.startsWith("-Xmx")) {
containsXmx = true;
}
}
if (!containsXmx) {
options.jFlags("-Xmx" + maxMemory);
}
}
options.setSourceNames(sourceNames());
executeExternalJavadoc(options);
}
use of org.gradle.internal.jvm.JavaModuleDetector in project gradle by gradle.
the class Test method createTestExecutionSpec.
/**
* {@inheritDoc}
*
* @since 4.4
*/
@Override
protected JvmTestExecutionSpec createTestExecutionSpec() {
validateToolchainConfiguration();
JavaForkOptions javaForkOptions = getForkOptionsFactory().newJavaForkOptions();
copyTo(javaForkOptions);
JavaModuleDetector javaModuleDetector = getJavaModuleDetector();
boolean testIsModule = javaModuleDetector.isModule(modularity.getInferModulePath().get(), getTestClassesDirs());
FileCollection classpath = javaModuleDetector.inferClasspath(testIsModule, stableClasspath);
FileCollection modulePath = javaModuleDetector.inferModulePath(testIsModule, stableClasspath);
return new JvmTestExecutionSpec(getTestFramework(), classpath, modulePath, getCandidateClassFiles(), isScanForTestClasses(), getTestClassesDirs(), getPath(), getIdentityPath(), getForkEvery(), javaForkOptions, getMaxParallelForks(), getPreviousFailedTestClasses());
}
use of org.gradle.internal.jvm.JavaModuleDetector in project gradle by gradle.
the class JavaCompile method createSpec.
DefaultJavaCompileSpec createSpec() {
validateConfiguration();
List<File> sourcesRoots = CompilationSourceDirs.inferSourceRoots((FileTreeInternal) getStableSources().getAsFileTree());
JavaModuleDetector javaModuleDetector = getJavaModuleDetector();
boolean isModule = JavaModuleDetector.isModuleSource(modularity.getInferModulePath().get(), sourcesRoots);
boolean toolchainCompatibleWithJava8 = isToolchainCompatibleWithJava8();
boolean isSourcepathUserDefined = compileOptions.getSourcepath() != null && !compileOptions.getSourcepath().isEmpty();
final DefaultJavaCompileSpec spec = createBaseSpec();
spec.setDestinationDir(getDestinationDirectory().getAsFile().get());
spec.setWorkingDir(getProjectLayout().getProjectDirectory().getAsFile());
spec.setTempDir(getTemporaryDir());
spec.setCompileClasspath(ImmutableList.copyOf(javaModuleDetector.inferClasspath(isModule, getClasspath())));
spec.setModulePath(ImmutableList.copyOf(javaModuleDetector.inferModulePath(isModule, getClasspath())));
if (isModule && !isSourcepathUserDefined) {
compileOptions.setSourcepath(getProjectLayout().files(sourcesRoots));
}
spec.setAnnotationProcessorPath(compileOptions.getAnnotationProcessorPath() == null ? ImmutableList.of() : ImmutableList.copyOf(compileOptions.getAnnotationProcessorPath()));
configureCompatibilityOptions(spec);
spec.setSourcesRoots(sourcesRoots);
if (!toolchainCompatibleWithJava8) {
spec.getCompileOptions().setHeaderOutputDirectory(null);
}
return spec;
}
Aggregations