Java Code Examples for org.gradle.util.DeprecationLogger#whileDisabled()

The following examples show how to use org.gradle.util.DeprecationLogger#whileDisabled() . 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: AbstractOptions.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Map<String, Object> optionMap() {
    final Class<?> thisClass = getClass();
    return DeprecationLogger.whileDisabled(new Factory<Map<String, Object>>() {
        public Map<String, Object> create() {
            Map<String, Object> map = Maps.newHashMap();
            Class<?> currClass = thisClass;
            if (currClass.getName().endsWith("_Decorated")) {
                currClass = currClass.getSuperclass();
            }
            while (currClass != AbstractOptions.class) {
                for (Field field : currClass.getDeclaredFields()) {
                    if (isOptionField(field)) {
                        addValueToMapIfNotNull(map, field);
                    }
                }
                currClass = currClass.getSuperclass();
            }
            return map;
        }
    });
}
 
Example 2
Source File: SourceTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.
 *
 * @return The source.
 */
@InputFiles
@SkipWhenEmpty
public FileTree getSource() {
    FileTree src;
    if (this.source.isEmpty()) {
        src = DeprecationLogger.whileDisabled(new Factory<FileTree>() {
            public FileTree create() {
                return getDefaultSource();
            }
        });
    } else {
        src = getProject().files(new ArrayList<Object>(this.source)).getAsFileTree();
    }
    return src == null ? getProject().files().getAsFileTree() : src.matching(patternSet);
}
 
Example 3
Source File: SourceTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.
 *
 * @return The source.
 */
@InputFiles
@SkipWhenEmpty
public FileTree getSource() {
    FileTree src;
    if (this.source.isEmpty()) {
        src = DeprecationLogger.whileDisabled(new Factory<FileTree>() {
            public FileTree create() {
                return getDefaultSource();
            }
        });
    } else {
        src = getProject().files(new ArrayList<Object>(this.source)).getAsFileTree();
    }
    return src == null ? getProject().files().getAsFileTree() : src.matching(patternSet);
}
 
Example 4
Source File: AbstractOptions.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Map<String, Object> optionMap() {
    final Class<?> thisClass = getClass();
    return DeprecationLogger.whileDisabled(new Factory<Map<String, Object>>() {
        public Map<String, Object> create() {
            Map<String, Object> map = Maps.newHashMap();
            Class<?> currClass = thisClass;
            if (currClass.getName().endsWith("_Decorated")) {
                currClass = currClass.getSuperclass();
            }
            while (currClass != AbstractOptions.class) {
                for (Field field : currClass.getDeclaredFields()) {
                    if (isOptionField(field)) {
                        addValueToMapIfNotNull(map, field);
                    }
                }
                currClass = currClass.getSuperclass();
            }
            return map;
        }
    });
}
 
Example 5
Source File: MinimalJavaCompileOptions.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public MinimalJavaCompileOptions(final CompileOptions compileOptions) {
    FileCollection sourcepath = compileOptions.getSourcepath();
    this.sourcepath = sourcepath == null ? null : ImmutableList.copyOf(sourcepath.getFiles());
    this.compilerArgs = Lists.newArrayList(compileOptions.getAllCompilerArgs());
    this.encoding = compileOptions.getEncoding();
    this.bootClasspath = DeprecationLogger.whileDisabled(new Factory<String>() {
        @Nullable
        @Override
        @SuppressWarnings("deprecation")
        public String create() {
            return compileOptions.getBootClasspath();
        }
    });
    this.extensionDirs = compileOptions.getExtensionDirs();
    this.forkOptions = compileOptions.getForkOptions();
    this.debugOptions = compileOptions.getDebugOptions();
    this.debug = compileOptions.isDebug();
    this.deprecation = compileOptions.isDeprecation();
    this.failOnError = compileOptions.isFailOnError();
    this.listFiles = compileOptions.isListFiles();
    this.verbose = compileOptions.isVerbose();
    this.warnings = compileOptions.isWarnings();
    this.annotationProcessorGeneratedSourcesDirectory = compileOptions.getAnnotationProcessorGeneratedSourcesDirectory();
}
 
Example 6
Source File: GroovyCompilerFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
Compiler<GroovyJavaJointCompileSpec> create(final GroovyCompileOptions groovyOptions, final CompileOptions javaOptions) {
    return DeprecationLogger.whileDisabled(new Factory<Compiler<GroovyJavaJointCompileSpec>>() {
        public Compiler<GroovyJavaJointCompileSpec> create() {
            // Some sanity checking of options
            if (groovyOptions.isUseAnt() && !javaOptions.isUseAnt()) {
                LOGGER.warn("When groovyOptions.useAnt is enabled, options.useAnt must also be enabled. Ignoring options.useAnt = false.");
                javaOptions.setUseAnt(true);
            } else if (!groovyOptions.isUseAnt() && javaOptions.isUseAnt()) {
                LOGGER.warn("When groovyOptions.useAnt is disabled, options.useAnt must also be disabled. Ignoring options.useAnt = true.");
                javaOptions.setUseAnt(false);
            }

            if (groovyOptions.isUseAnt()) {
                return new AntGroovyCompiler(antBuilder, classPathRegistry);
            }

            javaCompilerFactory.setJointCompilation(true);
            Compiler<JavaCompileSpec> javaCompiler = javaCompilerFactory.create(javaOptions);
            Compiler<GroovyJavaJointCompileSpec> groovyCompiler = new ApiGroovyCompiler(javaCompiler);
            CompilerDaemonFactory daemonFactory;
            if (groovyOptions.isFork()) {
                daemonFactory = compilerDaemonManager;
            } else {
                daemonFactory = inProcessCompilerDaemonFactory;
            }
            groovyCompiler = new DaemonGroovyCompiler(project, groovyCompiler, daemonFactory);
            return new NormalizingGroovyCompiler(groovyCompiler);
        }
    });
}
 
Example 7
Source File: AbstractProject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Project dependsOnChildren() {
    DeprecationLogger.nagUserOfDiscontinuedMethod("Project.dependsOnChildren()");
    return DeprecationLogger.whileDisabled(new Factory<Project>() {
        public Project create() {
            return dependsOnChildren(false);
        }
    });
}
 
Example 8
Source File: AbstractProject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Project childrenDependOnMe() {
    DeprecationLogger.nagUserOfDiscontinuedMethod("Project.childrenDependOnMe()");
    DeprecationLogger.whileDisabled(new Factory<Void>() {
        public Void create() {
            for (Project project : childProjects.values()) {
                project.dependsOn(getPath(), false);
            }
            return null;
        }
    });

    return this;
}
 
Example 9
Source File: AbstractProject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void dependsOn(final String path) {
    DeprecationLogger.nagUserOfDiscontinuedMethod("Project.dependsOn(String path)");
    DeprecationLogger.whileDisabled(new Factory<Void>() {
        public Void create() {
            dependsOn(path, true);
            return null;
        }
    });
}
 
Example 10
Source File: AbstractCopyTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns the source files for this task.
 * @return The source files. Never returns null.
 */
@InputFiles @SkipWhenEmpty @Optional
public FileCollection getSource() {
    if (rootSpec.hasSource()){
        return rootSpec.getAllSource();
    }else{
        return DeprecationLogger.whileDisabled(new Factory<FileCollection>() {
            public FileCollection create() {
                return getDefaultSource();
            }
        });
    }
}
 
Example 11
Source File: AbstractProject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Map<String, ?> getProperties() {
    return DeprecationLogger.whileDisabled(new Factory<Map<String, ?>>() {
        public Map<String, ?> create() {
            return extensibleDynamicObject.getProperties();
        }
    });
}
 
Example 12
Source File: AbstractProject.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Map<String, ?> getProperties() {
    return DeprecationLogger.whileDisabled(new Factory<Map<String, ?>>() {
        public Map<String, ?> create() {
            return extensibleDynamicObject.getProperties();
        }
    });
}
 
Example 13
Source File: AbstractProject.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Map<String, ?> getProperties() {
    return DeprecationLogger.whileDisabled(new Factory<Map<String, ?>>() {
        public Map<String, ?> create() {
            return extensibleDynamicObject.getProperties();
        }
    });
}
 
Example 14
Source File: AbstractProject.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Project dependsOnChildren(final boolean evaluateDependsOnProject) {
    DeprecationLogger.nagUserOfDiscontinuedMethod("Project.dependsOnChildren(boolean)");
    DeprecationLogger.whileDisabled(new Factory<Void>() {
        public Void create() {
            for (Project project : childProjects.values()) {
                dependsOn(project.getPath(), evaluateDependsOnProject);
            }
            return null;
        }
    });
    return this;
}
 
Example 15
Source File: GroovyCompilerFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
Compiler<GroovyJavaJointCompileSpec> create(final GroovyCompileOptions groovyOptions, final CompileOptions javaOptions) {
    return DeprecationLogger.whileDisabled(new Factory<Compiler<GroovyJavaJointCompileSpec>>() {
        public Compiler<GroovyJavaJointCompileSpec> create() {
            // Some sanity checking of options
            if (groovyOptions.isUseAnt() && !javaOptions.isUseAnt()) {
                LOGGER.warn("When groovyOptions.useAnt is enabled, options.useAnt must also be enabled. Ignoring options.useAnt = false.");
                javaOptions.setUseAnt(true);
            } else if (!groovyOptions.isUseAnt() && javaOptions.isUseAnt()) {
                LOGGER.warn("When groovyOptions.useAnt is disabled, options.useAnt must also be disabled. Ignoring options.useAnt = true.");
                javaOptions.setUseAnt(false);
            }

            if (groovyOptions.isUseAnt()) {
                return new AntGroovyCompiler(antBuilder, classPathRegistry);
            }

            javaCompilerFactory.setJointCompilation(true);
            Compiler<JavaCompileSpec> javaCompiler = javaCompilerFactory.create(javaOptions);
            Compiler<GroovyJavaJointCompileSpec> groovyCompiler = new ApiGroovyCompiler(javaCompiler);
            CompilerDaemonFactory daemonFactory;
            if (groovyOptions.isFork()) {
                daemonFactory = compilerDaemonManager;
            } else {
                daemonFactory = inProcessCompilerDaemonFactory;
            }
            groovyCompiler = new DaemonGroovyCompiler(project, groovyCompiler, daemonFactory);
            return new NormalizingGroovyCompiler(groovyCompiler);
        }
    });
}
 
Example 16
Source File: AbstractProject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Map<String, ?> getProperties() {
    return DeprecationLogger.whileDisabled(new Factory<Map<String, ?>>() {
        public Map<String, ?> create() {
            return extensibleDynamicObject.getProperties();
        }
    });
}
 
Example 17
Source File: AbstractProject.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void dependsOn(final String path) {
    DeprecationLogger.nagUserOfDiscontinuedMethod("Project.dependsOn(String path)");
    DeprecationLogger.whileDisabled(new Factory<Void>() {
        public Void create() {
            dependsOn(path, true);
            return null;
        }
    });
}
 
Example 18
Source File: AbstractCopyTask.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns the source files for this task.
 * @return The source files. Never returns null.
 */
@InputFiles @SkipWhenEmpty @Optional
public FileCollection getSource() {
    if (rootSpec.hasSource()){
        return rootSpec.getAllSource();
    }else{
        return DeprecationLogger.whileDisabled(new Factory<FileCollection>() {
            public FileCollection create() {
                return getDefaultSource();
            }
        });
    }
}
 
Example 19
Source File: InProcessGradleExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private BuildResult doRun(final OutputListenerImpl outputListener, OutputListenerImpl errorListener, BuildListenerImpl listener) {
    // Capture the current state of things that we will change during execution
    InputStream originalStdIn = System.in;
    Properties originalSysProperties = new Properties();
    originalSysProperties.putAll(System.getProperties());
    File originalUserDir = new File(originalSysProperties.getProperty("user.dir"));
    Map<String, String> originalEnv = new HashMap<String, String>(System.getenv());

    // Augment the environment for the execution
    System.setIn(getStdin());
    processEnvironment.maybeSetProcessDir(getWorkingDir());
    for (Map.Entry<String, String> entry : getEnvironmentVars().entrySet()) {
        processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue());
    }
    Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties();
    System.getProperties().putAll(implicitJvmSystemProperties);

    StartParameter parameter = new StartParameter();
    parameter.setCurrentDir(getWorkingDir());
    parameter.setShowStacktrace(ShowStacktrace.ALWAYS);

    CommandLineParser parser = new CommandLineParser();
    DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
    converter.configure(parser);
    ParsedCommandLine parsedCommandLine = parser.parse(getAllArgs());

    BuildLayoutParameters layout = converter.getLayoutConverter().convert(parsedCommandLine);

    Map<String, String> properties = new HashMap<String, String>();
    new LayoutToPropertiesConverter().convert(layout, properties);
    converter.getSystemPropertiesConverter().convert(parsedCommandLine, properties);

    new PropertiesToStartParameterConverter().convert(properties, parameter);
    converter.convert(parsedCommandLine, parameter);

    DefaultGradleLauncherFactory factory = DeprecationLogger.whileDisabled(new Factory<DefaultGradleLauncherFactory>() {
        public DefaultGradleLauncherFactory create() {
            return (DefaultGradleLauncherFactory) GradleLauncher.getFactory();
        }
    });
    factory.addListener(listener);
    GradleLauncher gradleLauncher = factory.newInstance(parameter);
    gradleLauncher.addStandardOutputListener(outputListener);
    gradleLauncher.addStandardErrorListener(errorListener);
    try {
        return gradleLauncher.run();
    } finally {
        // Restore the environment
        System.setProperties(originalSysProperties);
        processEnvironment.maybeSetProcessDir(originalUserDir);
        for (String envVar: getEnvironmentVars().keySet()) {
            String oldValue = originalEnv.get(envVar);
            if (oldValue != null) {
                processEnvironment.maybeSetEnvironmentVariable(envVar, oldValue);
            } else {
                processEnvironment.maybeRemoveEnvironmentVariable(envVar);
            }
        }
        factory.removeListener(listener);
        System.setIn(originalStdIn);
    }
}
 
Example 20
Source File: InProcessGradleExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private BuildResult doRun(final OutputListenerImpl outputListener, OutputListenerImpl errorListener, BuildListenerImpl listener) {
    // Capture the current state of things that we will change during execution
    InputStream originalStdIn = System.in;
    Properties originalSysProperties = new Properties();
    originalSysProperties.putAll(System.getProperties());
    File originalUserDir = new File(originalSysProperties.getProperty("user.dir"));
    Map<String, String> originalEnv = new HashMap<String, String>(System.getenv());

    // Augment the environment for the execution
    System.setIn(getStdin());
    processEnvironment.maybeSetProcessDir(getWorkingDir());
    for (Map.Entry<String, String> entry : getEnvironmentVars().entrySet()) {
        processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue());
    }
    Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties();
    System.getProperties().putAll(implicitJvmSystemProperties);

    StartParameter parameter = new StartParameter();
    parameter.setCurrentDir(getWorkingDir());
    parameter.setShowStacktrace(ShowStacktrace.ALWAYS);

    CommandLineParser parser = new CommandLineParser();
    DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
    converter.configure(parser);
    ParsedCommandLine parsedCommandLine = parser.parse(getAllArgs());

    BuildLayoutParameters layout = converter.getLayoutConverter().convert(parsedCommandLine);

    Map<String, String> properties = new HashMap<String, String>();
    new LayoutToPropertiesConverter().convert(layout, properties);
    converter.getSystemPropertiesConverter().convert(parsedCommandLine, properties);

    new PropertiesToStartParameterConverter().convert(properties, parameter);
    converter.convert(parsedCommandLine, parameter);

    DefaultGradleLauncherFactory factory = DeprecationLogger.whileDisabled(new Factory<DefaultGradleLauncherFactory>() {
        public DefaultGradleLauncherFactory create() {
            return (DefaultGradleLauncherFactory) GradleLauncher.getFactory();
        }
    });
    factory.addListener(listener);
    GradleLauncher gradleLauncher = factory.newInstance(parameter);
    gradleLauncher.addStandardOutputListener(outputListener);
    gradleLauncher.addStandardErrorListener(errorListener);
    try {
        return gradleLauncher.run();
    } finally {
        // Restore the environment
        System.setProperties(originalSysProperties);
        processEnvironment.maybeSetProcessDir(originalUserDir);
        for (String envVar: getEnvironmentVars().keySet()) {
            String oldValue = originalEnv.get(envVar);
            if (oldValue != null) {
                processEnvironment.maybeSetEnvironmentVariable(envVar, oldValue);
            } else {
                processEnvironment.maybeRemoveEnvironmentVariable(envVar);
            }
        }
        factory.removeListener(listener);
        System.setIn(originalStdIn);
    }
}