Maven: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
<source lang="xml">
<syntaxhighlight lang="xml">
<profile>
<profile>
     <id>ext</id>
     <id>ext</id>
Line 8: Line 8:
     </activation>
     </activation>
</profile>
</profile>
</source>
</syntaxhighlight>


==Distribution==
==Distribution==
<source lang="xml">
<syntaxhighlight lang="xml">
<settings>
<settings>
     [...]
     [...]
Line 18: Line 18:
         <id>nex</id>
         <id>nex</id>
         <properties>
         <properties>
             <altSnapshotDeploymentRepository>snapshots::default::https://nex.chorke.org/repository/maven/snapshots</altSnapshotDeploymentRepository>
             <altSnapshotDeploymentRepository>academia.snapshots::default::https://nex.chorke.org/repository/maven/snapshots</altSnapshotDeploymentRepository>
             <altReleaseDeploymentRepository>releases::default::https://nex.chorke.org/repository/maven/releases</altReleaseDeploymentRepository>
             <altReleaseDeploymentRepository>academia.releases::default::https://nex.chorke.org/repository/maven/releases</altReleaseDeploymentRepository>
         </properties>
         </properties>
         </profile>
         </profile>
     </profiles>
     </profiles>
</settings>
</settings>
</source>
</syntaxhighlight>


==Security==
==Security==
<source lang="bash">
<syntaxhighlight lang="bash">
M2_MASTER_PASS='academia';\
M2_MASTER_PASS='<master.password>';\
M2_SECURITY_XML="${HOME}/.m2/settings-security.xml";\
M2_SECURITY_XML="${HOME}/.m2/settings-security.xml";\
printf -v M2_MASTER_HASH '%s' $(mvn --encrypt-master-password ${M2_MASTER_PASS});\
printf -v M2_MASTER_HASH '%s' $(mvn --encrypt-master-password ${M2_MASTER_PASS});\
Line 39: Line 39:
EOF
EOF
fi
fi
</source>
</syntaxhighlight>
----
----
<source lang="bash">
<syntaxhighlight lang="bash">
M2_NEXUS_USER='<nexus.username>';\
M2_NEXUS_USER='<nexus.username>';\
M2_NEXUS_PASS='<nexus.password>';\
M2_NEXUS_PASS='<nexus.password>';\
Line 54: Line 54:
  <servers>
  <servers>
     <server>
     <server>
       <id>finology-releases</id>
       <id>academia.releases</id>
         <username>${M2_NEXUS_USER}</username>
         <username>${M2_NEXUS_USER}</username>
         <password>${M2_NEXUS_HASH}</password>
         <password>${M2_NEXUS_HASH}</password>
     </server>
     </server>
     <server>
     <server>
       <id>finology-snapshots</id>
       <id>academia.snapshots</id>
         <username>${M2_NEXUS_USER}</username>
         <username>${M2_NEXUS_USER}</username>
         <password>${M2_NEXUS_HASH}</password>
         <password>${M2_NEXUS_HASH}</password>
Line 67: Line 67:
   <mirrors>
   <mirrors>
     <mirror>
     <mirror>
       <id>finology</id>
       <id>academia</id>
       <mirrorOf>*</mirrorOf>
       <mirrorOf>*</mirrorOf>
       <url>https://nexus.finology.group/repository/maven-public/</url>
       <url>https://cdn.chorke.org/nexus/repository/m2/</url>
     </mirror>
     </mirror>
   </mirrors>
   </mirrors>
Line 75: Line 75:
   <profiles>
   <profiles>
     <profile>
     <profile>
       <id>finology</id>
       <id>academia</id>
      <properties>
        <altSnapshotDeploymentRepository>academia.snapshots::default::https://cdn.chorke.org/nexus/repository/m2-snapshots</altSnapshotDeploymentRepository>
        <altReleaseDeploymentRepository>academia.releases::default::https://cdn.chorke.org/nexus/repository/m2-releases</altReleaseDeploymentRepository>
      </properties>
       <repositories>
       <repositories>
         <repository>
         <repository>
Line 96: Line 100:
    
    
   <activeProfiles>
   <activeProfiles>
     <activeProfile>nexus</activeProfile>
     <activeProfile>academia</activeProfile>
   </activeProfiles>
   </activeProfiles>
</settings>
</settings>
EOF
EOF
fi
fi
</source>
</syntaxhighlight>


==References==
==References==
{|
| valign="top" |
* [https://stackoverflow.com/questions/41611671/ <code>altDeploymentRepository</code> vs. <code>altReleaseDeploymentRepository</code>]
* [https://stackoverflow.com/questions/3298135 Externalized Maven Distribution Management]
* [https://stackoverflow.com/questions/3298135 Externalized Maven Distribution Management]
* [http://maven.apache.org/ref/3.3.3/maven-model/maven.html#class_file File specification used to activate the profile]
* [http://maven.apache.org/ref/3.3.3/maven-model/maven.html#class_file File specification used to activate the profile]
Line 109: Line 116:
* [https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html Maven Deploy Optional Parameters]
* [https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html Maven Deploy Optional Parameters]
* [https://maven.apache.org/guides/mini/guide-encryption.html Maven Encrypt Master Password]
* [https://maven.apache.org/guides/mini/guide-encryption.html Maven Encrypt Master Password]
* [[Maven Deploy External JAR]]
* [https://stackoverflow.com/questions/23929235/ Bash Multi-line string]
* [[Nexus:Maven]]
* [[Nexus]]
| valign="top" |
* [https://mvnrepository.com/artifact/com.gkatzioura.maven.cloud/s3-storage-wagon Maven » S3 Storage Wagon]
* [[Maven Checkstyle Plugin]]
* [[Maven Release Plugin]]
| valign="top" |
|-
| colspan="3" |
----
|-
| valign="top" |
* [[CocoaPods]]
* [[Conan]]
* [[Bazel]]
* [[Bazel]]
* [[NPM]]
* [[Ant]]
* [[Ivy]]
| valign="top" |
| valign="top" |
|}

Latest revision as of 20:36, 4 November 2024

<profile>
    <id>ext</id>
    <activation>
        <file>
            <missing>${basedir}/ext</missing>
        </file>
    </activation>
</profile>

Distribution

<settings>
    [...]
    <profiles>
        <profile>
        <id>nex</id>
        <properties>
            <altSnapshotDeploymentRepository>academia.snapshots::default::https://nex.chorke.org/repository/maven/snapshots</altSnapshotDeploymentRepository>
            <altReleaseDeploymentRepository>academia.releases::default::https://nex.chorke.org/repository/maven/releases</altReleaseDeploymentRepository>
        </properties>
        </profile>
    </profiles>
</settings>

Security

M2_MASTER_PASS='<master.password>';\
M2_SECURITY_XML="${HOME}/.m2/settings-security.xml";\
printf -v M2_MASTER_HASH '%s' $(mvn --encrypt-master-password ${M2_MASTER_PASS});\
if  [ ! -f ${M2_SECURITY_XML} ]||[ ! -s ${M2_SECURITY_XML} ];then\
  cat << EOF | tee ${M2_SECURITY_XML} >/dev/null
<?xml version="1.0" encoding="UTF-8"?>
<settingsSecurity>
  <master>${M2_MASTER_HASH}</master>
</settingsSecurity>
EOF
fi

M2_NEXUS_USER='<nexus.username>';\
M2_NEXUS_PASS='<nexus.password>';\
M2_SETTINGS_XML="${HOME}/.m2/settings.xml";\
printf -v M2_NEXUS_HASH '%s' $(mvn --encrypt-password ${M2_NEXUS_PASS});\
if  [ ! -f ${M2_SETTINGS_XML} ]||[ ! -s ${M2_SETTINGS_XML} ];then\
  cat << EOF | tee ${M2_SETTINGS_XML} >/dev/null
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
 <servers>
    <server>
      <id>academia.releases</id>
        <username>${M2_NEXUS_USER}</username>
        <password>${M2_NEXUS_HASH}</password>
    </server>
    <server>
      <id>academia.snapshots</id>
        <username>${M2_NEXUS_USER}</username>
        <password>${M2_NEXUS_HASH}</password>
     </server>
  </servers>

  <mirrors>
    <mirror>
      <id>academia</id>
      <mirrorOf>*</mirrorOf>
      <url>https://cdn.chorke.org/nexus/repository/m2/</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>academia</id>
      <properties>
        <altSnapshotDeploymentRepository>academia.snapshots::default::https://cdn.chorke.org/nexus/repository/m2-snapshots</altSnapshotDeploymentRepository>
        <altReleaseDeploymentRepository>academia.releases::default::https://cdn.chorke.org/nexus/repository/m2-releases</altReleaseDeploymentRepository>
      </properties>
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  
  <activeProfiles>
    <activeProfile>academia</activeProfile>
  </activeProfiles>
</settings>
EOF
fi

References