Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix wrong maven dependency versions in binariesembedded-list. #5939

Merged
merged 1 commit into from
May 12, 2023

Conversation

mbien
Copy link
Member

@mbien mbien commented May 12, 2023

No description provided.

@mbien mbien added the Maven [ci] enable "build tools" tests label May 12, 2023
@mbien mbien added this to the NB18 milestone May 12, 2023
@neilcsmith-net neilcsmith-net requested a review from ebarboni May 12, 2023 09:21
@ebarboni
Copy link
Contributor

@mbien I'm very sorry for the overhead.

groupid for commons-codec is wrong should be commons-codec:commons-codec:1.11 (not seen commons-codec in org.apache.commons)
groupid for org.aopalliance is wrong should be aopalliance:aopalliance:1.0 (not seen org.aopalliance in the central repo)
typo too many : in the maven-resolver-provider should be org.apache.maven:maven-resolver-provider:3.9.1 (if I'm correct)

@ebarboni ebarboni added the priority:critical Showstopper issue that requires fixing in next release label May 12, 2023
@mbien mbien changed the title fix wrong maven dependency version in binariesembedded-list. fix wrong maven dependency versions in binariesembedded-list. May 12, 2023
@mbien mbien force-pushed the fix-binaries-embedded-version branch from cc6d533 to 1dce54b Compare May 12, 2023 11:32
@mbien
Copy link
Member Author

mbien commented May 12, 2023

updated

@mbien mbien marked this pull request as ready for review May 12, 2023 11:34
@mbien mbien force-pushed the fix-binaries-embedded-version branch from 1dce54b to 7ae5124 Compare May 12, 2023 11:55
@mbien
Copy link
Member Author

mbien commented May 12, 2023

quickly wrote a util which generates a maven dependency section:

package dev.mbien.embedderlist;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Stream;

/**
 * @author mbien
 */
public class Embedderlist {

    public static void main(String[] args) throws IOException, InterruptedException {
        Path path = Path.of("/home/mbien/NetBeansProjects/netbeans/java/maven.embedder/external/binariesembedded-list");
        
        StringBuilder sb = new StringBuilder();
        sb.append(
            """
            <?xml version="1.0" encoding="UTF-8"?>
            <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
                <modelVersion>4.0.0</modelVersion>
                <groupId>com.mycompany</groupId>
                <artifactId>mavenproject1</artifactId>
                <version>1.0-SNAPSHOT</version>
                <packaging>jar</packaging>
                <properties>
                    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                    <maven.compiler.release>11</maven.compiler.release>
                </properties>
                <dependencies>
            """
        );
        
        try(Stream<String> lines = Files.lines(path)) {
            // 321C614F85F1DEA6BB08C1817C60D53B7F3552FD;org.fusesource.jansi:jansi:2.4.0
            lines.filter(l -> !l.startsWith("#") && l.contains(";"))
                 .map(l -> l.substring(l.indexOf(';')+1))
                 .forEach(l -> {
                String[] comp = l.split("\\:");
                sb.append(
                    """
                            <dependency>
                                <groupId>%s</groupId>
                                <artifactId>%s</artifactId>
                                <version>%s</version>
                            </dependency>
                    """.formatted(comp[0], comp[1], comp[2]));
            });
            
        }
        sb.append(
            """
                </dependencies>
            </project>
            """);
        
        Path tmp = Files.createTempDirectory("dep-check-o-matic");
        Files.writeString(tmp.resolve("pom.xml"), sb.toString());
        new ProcessBuilder(List.of("mvn", "clean", "install"))
                .directory(tmp.toFile())
                .redirectError(tmp.resolve("error.log").toFile())
                .redirectOutput(tmp.resolve("out.log").toFile())
                .start()
                .waitFor();
        
        System.out.println("##############################");
        System.out.println(Files.readString(tmp.resolve("out.log")));
        System.out.println("##############################");
        
    }
}

then pasted it into a project and hit clean build. This found another typo which I fixed.

@neilcsmith-net
Copy link
Member

@mbien you and me both in different ways! 😄 master...neilcsmith-net:netbeans:fix-binaries-embedded-version

Please consider the test task update - run using ant -f java/maven.embedder/ checkhash. It should now pick up wrong filenames as well as missing hashes.

update ant task a bit.

Co-authored-by: Neil C Smith <neilcsmith@apache.org>
@mbien mbien force-pushed the fix-binaries-embedded-version branch from 7ae5124 to 2c3ee44 Compare May 12, 2023 12:42
@mbien
Copy link
Member Author

mbien commented May 12, 2023

applied the changes to the ant task. We should probably store the dependencies in a pom right away and let ant parse it :)

gives us editor support and error checks for free.

@neilcsmith-net
Copy link
Member

Thanks. Well, I'd certainly like to generate the list and hashes from the info in the jars. A job for NB19!

@ebarboni is the checkhash task run at any point?

@mbien
Copy link
Member Author

mbien commented May 12, 2023

requesting a sync back to master once its on delivery so that I can do the same thing again for maven 3.9.2 in the other PR

@neilcsmith-net
Copy link
Member

Don't worry. Anything added to delivery until the release will be synced to master. May be a few days, until after 18-rc4 is built.

@ebarboni
Copy link
Contributor

checkhash is to be run manually If I remember well. Helper only.

But the javax.annotation is generated well on the pom because hash is populated first bcevause getallmavencoordinate build a concat of every binaries-list + binariesembeded-list. I guess first found first returned.

I think downloading with "normal" download of external should fail also. it could be an option maybe.

@ebarboni
Copy link
Contributor

in nbbuild/build.xml

<target name="download-all-extbins" unless="ext.binaries.downloaded" depends="bootstrap">
    <echo>Downloading external binaries (*/external/ directories)...</echo>
    <!-- optionnal reporttofile used to speed resolving artefacts resolution for maven artefacts -->
    <downloadbinaries cache="${binaries.cache}" server="${binaries.server}" repos="${binaries.repos}"  >
        <manifest dir="${nb_all}">
            <include name="**/external/binaries-list"/>
            <include name="**/external/binariesembedded-list"/>
        </manifest>
    </downloadbinaries>
    <property name="ext.binaries.downloaded" value="true"/>
  </target>

this task is the one used mostly during build => may be hacked too but have to understand it first ;D

 <target name="download-selected-extbins" unless="ext.binaries.downloaded" depends="init-module-list">
    <echo>Downloading external binaries (*/external/ directories) for cluster.config=${cluster.config}...</echo>
    <pathconvert property="modules.binaries-list" pathsep=",">
        <path>
            <dirset dir="${nb_all}" includes="nbbuild,${allmodules}"/>
        </path>
        <map from="${nb_all}/" to=""/>
        <globmapper from="*" to="*/external/binaries-list"/>
    </pathconvert>
    <downloadbinaries cache="${binaries.cache}" server="${binaries.server}" repos="${binaries.repos}">
        <manifest dir="${nb_all}" includes="${modules.binaries-list}"/>
    </downloadbinaries>
  </target>

@neilcsmith-net
Copy link
Member

@ebarboni well, we could also change the extraction task in maven.embedder to run the test?

    <target name="-release.files" depends="projectized.-release.files">
        <mkdir dir="${cluster}/maven"/>
        <unzip src="external/${bundled.maven}-bin.zip" dest="${cluster}/maven">
            <mapper type="glob" from="${bundled.maven}/*" to="*"/>
        </unzip>
        <taskdef name="checkjarssha1" classname="org.netbeans.nbbuild.extlibs.CheckEmbeddedBinaries" classpath="${nbantext.jar}"/>
        <mkdir dir="build/tmptesting"/>
        <unzip src="external/${bundled.maven}-bin.zip" dest="build/tmptesting">
            <patternset>
                <include name="**/*.jar"/>
            </patternset>
            <mapper type="flatten"/>
        </unzip>
        <checkjarssha1 dir="build/tmptesting" shalist="external/binariesembedded-list" />
        <delete dir="build/tmptesting"/>
    </target>

@neilcsmith-net
Copy link
Member

neilcsmith-net commented May 12, 2023

Anyway, for delivery are we OK with merging this as it is now?

@mbien
Copy link
Member Author

mbien commented May 12, 2023

should be correct now

  • we know that the coordinates work with the help of the pom
  • the task checks the hashes
  • the zip has 48 jars, the list has 48 entries

@neilcsmith-net neilcsmith-net merged commit bf19d75 into apache:delivery May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maven [ci] enable "build tools" tests priority:critical Showstopper issue that requires fixing in next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants