org.gradle.util.DeprecationLogger Java Examples

The following examples show how to use org.gradle.util.DeprecationLogger. 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: DefaultArtifactRepositoryContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DependencyResolver addAfter(Object userDescription, final String beforeResolverName, Closure configureClosure) {
    if (!GUtil.isTrue(beforeResolverName)) {
        throw new InvalidUserDataException("You must specify beforeResolverName");
    }
    DeprecationLogger.nagUserOfDiscontinuedMethod("ArtifactRepositoryContainer.addAfter()");
    final ArtifactRepository before = getByName(beforeResolverName);

    return addCustomDependencyResolver(userDescription, configureClosure, new Action<ArtifactRepository>() {
        public void execute(ArtifactRepository repository) {
            int insertPos = indexOf(before) + 1;
            if (insertPos == size()) {
                DefaultArtifactRepositoryContainer.super.add(repository);
            } else {
                DefaultArtifactRepositoryContainer.this.add(insertPos, repository);
            }
        }
    });
}
 
Example #2
Source File: GradlePomModuleDescriptorBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void addMainArtifact(String artifactId, String packaging) {
    if ("pom".equals(packaging)) {
        return;
    }

    if (!isKnownJarPackaging(packaging)) {
        ModuleComponentIdentifier componentIdentifier = DefaultModuleComponentIdentifier.newId(mrid.getOrganisation(), mrid.getName(), mrid.getRevision());
        DefaultArtifact artifact = new DefaultArtifact(mrid, new Date(), artifactId, packaging, packaging);
        ModuleVersionArtifactMetaData artifactMetaData = new DefaultModuleVersionArtifactMetaData(componentIdentifier, artifact);
        if (parserSettings.artifactExists(artifactMetaData)) {
            ivyModuleDescriptor.addArtifact("master", artifact);

            DeprecationLogger.nagUserOfDeprecated("Relying on packaging to define the extension of the main artifact");
            return;
        }
    }

    ivyModuleDescriptor.addArtifact("master", new DefaultArtifact(mrid, new Date(), artifactId, packaging, "jar"));
}
 
Example #3
Source File: GradlePomModuleDescriptorBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void addMainArtifact(String artifactId, String packaging) {
    if ("pom".equals(packaging)) {
        return;
    }

    if (!isKnownJarPackaging(packaging)) {
        ModuleComponentIdentifier componentIdentifier = DefaultModuleComponentIdentifier.newId(mrid.getOrganisation(), mrid.getName(), mrid.getRevision());
        DefaultArtifact artifact = new DefaultArtifact(mrid, new Date(), artifactId, packaging, packaging);
        ModuleVersionArtifactMetaData artifactMetaData = new DefaultModuleVersionArtifactMetaData(componentIdentifier, artifact);
        if (parserSettings.artifactExists(artifactMetaData)) {
            ivyModuleDescriptor.addArtifact("master", artifact);

            DeprecationLogger.nagUserOfDeprecated("Relying on packaging to define the extension of the main artifact");
            return;
        }
    }

    ivyModuleDescriptor.addArtifact("master", new DefaultArtifact(mrid, new Date(), artifactId, packaging, "jar"));
}
 
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: 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 #6
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 #7
Source File: DefaultArtifactRepositoryContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DependencyResolver addAfter(Object userDescription, final String beforeResolverName, Closure configureClosure) {
    if (!GUtil.isTrue(beforeResolverName)) {
        throw new InvalidUserDataException("You must specify beforeResolverName");
    }
    DeprecationLogger.nagUserOfDiscontinuedMethod("ArtifactRepositoryContainer.addAfter()");
    final ArtifactRepository before = getByName(beforeResolverName);

    return addCustomDependencyResolver(userDescription, configureClosure, new Action<ArtifactRepository>() {
        public void execute(ArtifactRepository repository) {
            int insertPos = indexOf(before) + 1;
            if (insertPos == size()) {
                DefaultArtifactRepositoryContainer.super.add(repository);
            } else {
                DefaultArtifactRepositoryContainer.this.add(insertPos, repository);
            }
        }
    });
}
 
Example #8
Source File: AbstractProject.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @deprecated Use the {@link #mkdir(Object)} instead.
 */
@Deprecated
public Directory dir(String path) {
    DeprecationLogger.nagUserOfReplacedMethod("AbstractProject.dir()", "mkdir()");
    String[] pathElements = path.split("/");
    String name = "";
    Directory dirTask = null;
    for (String pathElement : pathElements) {
        name += name.length() != 0 ? "/" + pathElement : pathElement;
        Task task = taskContainer.findByName(name);
        if (task instanceof Directory) {
            dirTask = (Directory) task;
        } else if (task != null) {
            throw new InvalidUserDataException(String.format("Cannot add directory task '%s' as a non-directory task with this name already exists.", name));
        } else {
            dirTask = taskContainer.create(name, Directory.class);
        }
    }
    return dirTask;
}
 
Example #9
Source File: TaskStatusNagger.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void warn(String method) {
    if (executingleftShiftAction) {
        DeprecationLogger.nagUserOfDeprecated(String.format(DEPRECATION_MESSAGE, method), String.format(EXPLANAITION_WITH_HINT, taskInternal));
    } else {
        DeprecationLogger.nagUserOfDeprecated(String.format(DEPRECATION_MESSAGE, method), String.format(EXPLANAITION, taskInternal));
    }
}
 
Example #10
Source File: DefaultConfiguration.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void validateMutation() {
    if (getState() != State.UNRESOLVED) {
        throw new InvalidUserDataException(String.format("Cannot change %s after it has been resolved.", getDisplayName()));
    }
    if (includedInResult) {
        DeprecationLogger.nagUserOfDeprecatedBehaviour(String.format("Attempting to change %s after it has been included in dependency resolution", getDisplayName()));
    }
}
 
Example #11
Source File: MavenResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Deprecated
public void setUseMavenMetadata(boolean useMavenMetadata) {
    DeprecationLogger.nagUserOfDiscontinuedMethod("MavenResolver.setUseMavenMetadata(boolean)");
    this.useMavenMetadata = useMavenMetadata;
    if (useMavenMetadata) {
        this.versionLister = new ChainedVersionLister(
                new MavenVersionLister(getRepository()),
                new ResourceVersionLister(getRepository()));
    } else {
        this.versionLister = new ResourceVersionLister(getRepository());
    }
}
 
Example #12
Source File: Test.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Enables the HTML test report.
 *
 * @deprecated Replaced by {@code getReports().getHtml().setEnabled()}
 */
@SuppressWarnings("UnusedDeclaration")
@Deprecated
public void enableTestReport() {
    DeprecationLogger.nagUserOfReplacedProperty("Test.testReport", "Test.getReports().getHtml().setEnabled()");
    reports.getHtml().setEnabled(true);
}
 
Example #13
Source File: GroovyCompileOptions.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Tells whether the groovyc Ant task should be used over Gradle's own Groovy compiler integration.
 * Defaults to {@code false}.
 *
 * @deprecated No replacement
 */
@Input
@Deprecated
public boolean isUseAnt() {
    DeprecationLogger.nagUserOfDiscontinuedProperty("GroovyCompileOptions.useAnt", "There is no replacement for this property.");
    return useAnt;
}
 
Example #14
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 #15
Source File: CompileOptions.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Sets the compiler to be used. Only takes effect if {@code useAnt} is {@code true}.
 *
 * @deprecated use {@code CompileOptions.forkOptions.executable instead}
 */
@Deprecated
public void setCompiler(String compiler) {
    DeprecationLogger.nagUserOfDiscontinuedProperty("CompileOptions.compiler", "To use an alternative compiler, "
            + "set 'CompileOptions.fork' to 'true', and 'CompileOptions.forkOptions.executable' to the path of the compiler executable.");
    this.compiler = compiler;
}
 
Example #16
Source File: DefaultResolvedArtifact.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ResolvedDependency getResolvedDependency() {
    DeprecationLogger.nagUserOfDeprecated(
            "ResolvedArtifact.getResolvedDependency()",
            "For version info use ResolvedArtifact.getModuleVersion(), to access the dependency graph use ResolvedConfiguration.getFirstLevelModuleDependencies()"
    );
    //resolvedDependency is expensive so lazily create it
    return ownerSource.create();
}
 
Example #17
Source File: DefaultMavenFileLocations.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Nullable
public File getGlobalMavenDir() {
    String m2Home = System.getenv("M2_HOME");
    if (m2Home == null) {
        m2Home = System.getProperty("M2_HOME");
        if(m2Home==null){
            return null;
        }
        DeprecationLogger.nagUserOfDeprecated("Found defined M2_HOME system property. Handling M2_HOME system property", "Please use the M2_HOME environment variable instead");
    }
    return new File(m2Home);
}
 
Example #18
Source File: AbstractGradleExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected Map<String, String> getImplicitJvmSystemProperties() {
    Map<String, String> properties = new LinkedHashMap<String, String>();

    if (getUserHomeDir() != null) {
        properties.put("user.home", getUserHomeDir().getAbsolutePath());
    }

    properties.put(GradleProperties.IDLE_TIMEOUT_PROPERTY, "" + (daemonIdleTimeoutSecs * 1000));
    properties.put(GradleProperties.DAEMON_BASE_DIR_PROPERTY, daemonBaseDir.getAbsolutePath());
    properties.put(DeprecationLogger.ORG_GRADLE_DEPRECATION_TRACE_PROPERTY_NAME, "true");

    String tmpDirPath = getTmpDir().createDir().getAbsolutePath();
    if (!tmpDirPath.contains(" ") || getDistribution().isSupportsSpacesInGradleAndJavaOpts()) {
        properties.put("java.io.tmpdir", tmpDirPath);
    }

    properties.put("file.encoding", getDefaultCharacterEncoding());
    Locale locale = getDefaultLocale();
    if (locale != null) {
        properties.put("user.language", locale.getLanguage());
        properties.put("user.country", locale.getCountry());
        properties.put("user.variant", locale.getVariant());
    }

    if (eagerClassLoaderCreationChecksOn) {
        properties.put(DefaultClassLoaderScope.STRICT_MODE_PROPERTY, "true");
    }

    return properties;
}
 
Example #19
Source File: DefaultConfiguration.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void validateMutation() {
    if (getState() != State.UNRESOLVED) {
        throw new InvalidUserDataException(String.format("Cannot change %s after it has been resolved.", getDisplayName()));
    }
    if (includedInResult) {
        DeprecationLogger.nagUserOfDeprecatedBehaviour(String.format("Attempting to change %s after it has been included in dependency resolution", getDisplayName()));
    }
}
 
Example #20
Source File: ExtraPropertiesDynamicObjectAdapter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void setProperty(String name, Object value) throws MissingPropertyException {
    if (!dynamicOwner.hasProperty(name)) {
        DeprecationLogger.nagUserAboutDynamicProperty(name, delegate, value);
    }

    super.setProperty(name, value);
}
 
Example #21
Source File: ReportingBasePluginConvention.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Sets the name of the reports directory, relative to the project's build directory.
 *
 * @deprecated use {@link ReportingExtension#setBaseDir(Object)}
 * @param reportsDirName The reports directory name. Should not be null.
 */
@Deprecated
public void setReportsDirName(final String reportsDirName) {
    DeprecationLogger.nagUserOfReplacedProperty("reportsDirName", "reporting.baseDir");
    extension.setBaseDir(new Callable<File>() {
        public File call() throws Exception {
            return project.getServices().get(FileLookup.class).getFileResolver(project.getBuildDir()).resolve(reportsDirName);
        }
    });
}
 
Example #22
Source File: DefaultTaskContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Task resolveTask(Object path) {
    if (!GUtil.isTrue(path)) {
        throw new InvalidUserDataException("A path must be specified!");
    }
    if (!(path instanceof CharSequence)) {
        DeprecationLogger.nagUserOfDeprecated(
                String.format("Converting class %s to a task dependency using toString()", path.getClass().getName()),
                "Please use org.gradle.api.Task, java.lang.String, org.gradle.api.Buildable, org.gradle.tasks.TaskDependency or a Closure to declare your task dependencies"
        );
    }
    return getByPath(path.toString());
}
 
Example #23
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 #24
Source File: ExtraPropertiesDynamicObjectAdapter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void setProperty(String name, Object value) throws MissingPropertyException {
    if (!dynamicOwner.hasProperty(name)) {
        DeprecationLogger.nagUserAboutDynamicProperty(name, delegate, value);
    }

    super.setProperty(name, value);
}
 
Example #25
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 #26
Source File: DefaultArtifactRepositoryContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DependencyResolver addBefore(Object userDescription, final String afterResolverName, Closure configureClosure) {
    if (!GUtil.isTrue(afterResolverName)) {
        throw new InvalidUserDataException("You must specify afterResolverName");
    }
    DeprecationLogger.nagUserOfDiscontinuedMethod("ArtifactRepositoryContainer.addBefore()");
    final ArtifactRepository after = getByName(afterResolverName);
    return addCustomDependencyResolver(userDescription, configureClosure, new Action<ArtifactRepository>() {
        public void execute(ArtifactRepository repository) {
            DefaultArtifactRepositoryContainer.super.add(indexOf(after), repository);
        }
    });
}
 
Example #27
Source File: DefaultIvyDependencyPublisher.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean checkArtifactFileExists(ModuleVersionArtifactPublishMetaData artifact) {
    File artifactFile = artifact.getFile();
    if (artifactFile.exists()) {
        return true;
    }
    // TODO:DAZ This hack is required so that we don't log a warning when the Signing plugin is used. We need to allow conditional configurations so we can remove this.
    if (!isSigningArtifact(artifact.getArtifactName())) {
        String message = String.format("Attempted to publish an artifact '%s' that does not exist '%s'", artifact.getId(), artifactFile);
        DeprecationLogger.nagUserOfDeprecatedBehaviour(message);
    }
    return false;
}
 
Example #28
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 #29
Source File: DefaultExcludeRule.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Map<String, String> getExcludeArgs() {
    DeprecationLogger.nagUserOfDeprecated("The getExcludeArgs method", "Please use the getGroup() method or the getModule() method instead");
    Map excludeArgsAsMap = new HashMap();
    excludeArgsAsMap.put(ExcludeRule.GROUP_KEY, group);
    excludeArgsAsMap.put(ExcludeRule.MODULE_KEY, module);
    return excludeArgsAsMap;
}
 
Example #30
Source File: DefaultRepositoryHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public MavenArtifactRepository mavenCentral(Map<String, ?> args) {
    Map<String, Object> modifiedArgs = new HashMap<String, Object>(args);
    if (modifiedArgs.containsKey("urls")) {
        DeprecationLogger.nagUserOfDeprecated(
                "The 'urls' property of the RepositoryHandler.mavenCentral() method",
                "You should use the 'artifactUrls' property to define additional artifact locations"
        );
        List<?> urls = flattenCollections(modifiedArgs.remove("urls"));
        modifiedArgs.put("artifactUrls", urls);
    }

    return addRepository(repositoryFactory.createMavenCentralRepository(), DEFAULT_MAVEN_CENTRAL_REPO_NAME, new ConfigureByMapAction<MavenArtifactRepository>(modifiedArgs));
}