Publishing lib in maven central

Foreword



I decided to do something useful. There was a project in which we had to make a new one, but better instead of the old service. The service is great, 10k lines of business rules + 15k lines of Java code. Now it is twice as many. But since there is a lot of logic and no one really remembers much (that's why we were called upon to have tests, docks and a minimum of bugs), it was necessary to compare the old service and the new one. So that our testers would not die of old age, trying to check everything, I thought and wrote a service that pulled the old and new api, compared and merged the difference in answers into the database, so that the testers would check and we would fix the difference. But here's the problem, at the input we have many parameters and their possible values, these are billions of combinations, they will be checked for several months with full load, and there are many similar ones.

As a result, at first, the idea was born to take and reduce possible changes in parameters and generally throw out some of the enumeration, and then the Pairwise testing theory was adopted and it allowed throwing all the parameters and all values ​​and checking everything entirely.







This simple theory claims that if we create test cases where each pair of parameters occurs at least once, then we will cover almost 90% of the bugs. At the same time, you can choose everything so that there will be not billions of test cases, but maybe several thousand. Excellent result! As a result, we found hundreds of discrepancies and even a bunch of bugs in the legacy service, as well as made the writers of business logic think about something that they had never thought about before, since we just threw them new interesting test cases in which it was not clear "how right".







The code is written, everything works, everyone is happy, but somehow I didn't want to throw out the test case generator, so I sat down on the weekend and wrote a lib that used the same algorithm as in the working service, but was completely torn off from everything except lombok and was written outside office hours. Therefore, I wanted to publish it under the Apache 2.0 license in the maven central. But it was so dreary and poorly described that I decided to leave myself a memo on HabrΓ©, so that later, if suddenly, I would not suffer a second time.







If you suddenly need it, the libka is published here .







So let's go.







Register on sonatype.org



Publishing directly to Maven Central will not work just like that, so I used the intermediate service sonatype.org First, you need to register there.







They have documentation on how to release everything .







, pom.xml









: gnupg, maven release plugin . , git , . . . .







GNUpg



. , , . , . , GUI , . gpa , .







:







  1. .

    Imgur
  2. Ctrl+N.
  3. .
  4. , sonatype.org , . "" " ".

    Imgur

    .


settings.xml



Maven. sonatype.org ( ), .







<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <servers>
    <server>
      <id>ossrh</id>
      <username>3DRaven</username>
      <password>passwordForYourAccountInSonata</password>
    </server>
  </servers>
  <mirrors/>
  <proxies/>
  <profiles>
    <profile>
      <id>ossrh</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <gpg.executable>gpg2</gpg.executable>
        <gpg.passphrase>passwordForGPGKey</gpg.passphrase>
      </properties>
    </profile>
  </profiles>
  <activeProfiles/>
</settings>
      
      





ossrh .







pom.xml



, javadoc, source. . ,













<description>Generate array of minimal size of pairwise tests cover all pairs of changing params</description>
    <url>https://github.com/3DRaven/pairwiser</url>
    <inceptionYear>2020</inceptionYear>
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
            <comments>A business-friendly OSS license</comments>
        </license>
    </licenses>
    <developers>
        <developer>
            <id>3DRaven</id>
            <name>Renat Eskenin</name>
            <email>email</email>
        </developer>
    </developers>
    <scm>
        <connection>scm:git:ssh://git@github.com:3DRaven/pairwiser.git</connection>
        <developerConnection>scm:git:ssh://git@github.com:3DRaven/pairwiser.git</developerConnection>
        <tag>HEAD</tag>
        <url>https://github.com/3DRaven/pairwiser</url>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/3DRaven/pairwiser/issues</url>
    </issueManagement>
    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>
      
      





distributionManagement. , , id ossrh settings.xml . , javadoc source. profiles , . .







<profiles>
        <!-- GPG Signature on release -->
        <profile>
            <id>release-sign-artifacts</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven.gpg.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven.source.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven.javadoc.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
      
      





sonatype.org, staging . . Open . , "", . sonatype.org .







<plugin>
    <groupId>org.sonatype.plugins</groupId>
    <artifactId>nexus-staging-maven-plugin</artifactId>
    <version>${nexus.staging.maven.plugin.version}</version>
    <extensions>true</extensions>
    <configuration>
        <serverId>ossrh</serverId>
        <nexusUrl>https://oss.sonatype.org/</nexusUrl>
        <autoReleaseAfterClose>true</autoReleaseAfterClose>
    </configuration>
</plugin>
      
      







sonatype.org , , . Jira .







staging



, , , , sonatype.org







mvn release:clean release:prepare 
mvn release:perform
      
      





, , , "Close".









, , , . , Maven Central . ( ) . "", Close. , Release Drop. . , , Maven Central







!









  1. sonatype.org
  2. settings.xml
  3. pom.xml
  4. Go to sonatype.org and close, release and drop your repository
  5. PROFIT !!!



All Articles