public void populateArtifactInfo()

in indexer-core/src/main/java/org/apache/maven/index/creator/MinimalArtifactInfoIndexCreator.java [177:261]


    public void populateArtifactInfo(ArtifactContext ac) {
        File artifact = ac.getArtifact();

        File pom = ac.getPom();

        ArtifactInfo ai = ac.getArtifactInfo();

        if (pom != null && pom.isFile()) {
            ai.setLastModified(pom.lastModified());

            ai.setFileExtension("pom");
        }

        // TODO handle artifacts without poms
        if (pom != null && pom.isFile()) {
            if (ai.getClassifier() != null) {
                ai.setSourcesExists(ArtifactAvailability.NOT_AVAILABLE);

                ai.setJavadocExists(ArtifactAvailability.NOT_AVAILABLE);
            } else {
                File sources = sl.locate(pom);
                if (!sources.exists()) {
                    ai.setSourcesExists(ArtifactAvailability.NOT_PRESENT);
                } else {
                    ai.setSourcesExists(ArtifactAvailability.PRESENT);
                }

                File javadoc = jl.locate(pom);
                if (!javadoc.exists()) {
                    ai.setJavadocExists(ArtifactAvailability.NOT_PRESENT);
                } else {
                    ai.setJavadocExists(ArtifactAvailability.PRESENT);
                }
            }
        }

        Model model = ac.getPomModel();

        if (model != null) {
            ai.setName(model.getName());

            ai.setDescription(model.getDescription());

            // for main artifacts (without classifier) only:
            if (ai.getClassifier() == null) {
                // only when this is not a classified artifact
                if (model.getPackaging() != null) {
                    // set the read value that is coming from POM
                    ai.setPackaging(model.getPackaging());
                } else {
                    // default it, since POM is present, is read, but does not contain explicit packaging
                    // TODO: this change breaks junit tests, but not sure why is "null" expected value?
                    ai.setPackaging("jar");
                }
            }
        }

        if ("pom".equals(ai.getPackaging())) {
            // special case, the POM _is_ the artifact
            artifact = pom;
        }

        if (artifact != null) {
            File signature = sigl.locate(artifact);

            ai.setSignatureExists(signature.exists() ? ArtifactAvailability.PRESENT : ArtifactAvailability.NOT_PRESENT);

            File sha1 = sha1l.locate(artifact);

            if (sha1.exists()) {
                try {
                    ai.setSha1(
                            StringUtils.chomp(FileUtils.fileRead(sha1)).trim().split(" ")[0]);
                } catch (IOException e) {
                    ac.addError(e);
                }
            }

            ai.setLastModified(artifact.lastModified());

            ai.setSize(artifact.length());

            ai.setFileExtension(getExtension(artifact, ac.getGav()));
        }
    }