Skip to content

testNoSources checks directory existence instead of jar file absence #308

Description

@elharo

In SourceJarMojoTest.java:93-97 and TestSourceJarMojoTest.java:80-84:

public void testNoSources(AbstractSourceJarMojo mojo) throws Exception {
    mojo.execute();
    final File expectedFile = getTestTargetDir("project-005");
    assertFalse(
            expectedFile.exists(),
            "Source archive should not have been created[" + expectedFile.getAbsolutePath() + "]");
}

getTestTargetDir("project-005") returns /basedir/target/test-classes/unit/project-005/target — a directory, not the jar file itself. If the test environment pre-creates this directory (e.g., from a previous test run or build scaffolding), the assertion would fail even though no source archive was created.

A more robust check would verify the specific jar file does not exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:trivialCosmetic problem like misspelled words or misaligned text

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions