本文整理汇总了Java中org.apache.maven.artifact.repository.metadata.Metadata.setGroupId方法的典型用法代码示例。如果您正苦于以下问题:Java Metadata.setGroupId方法的具体用法?Java Metadata.setGroupId怎么用?Java Metadata.setGroupId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.artifact.repository.metadata.Metadata
的用法示例。
在下文中一共展示了Metadata.setGroupId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: a
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
private Metadata a(final String groupId,
final String artifactId,
final String lastUpdated,
final String latest,
final String release,
final String... versions)
{
final Metadata m = new Metadata();
m.setGroupId(groupId);
m.setArtifactId(artifactId);
m.setVersioning(new Versioning());
final Versioning mv = m.getVersioning();
if (!Strings.isNullOrEmpty(lastUpdated)) {
mv.setLastUpdated(lastUpdated);
}
if (!Strings.isNullOrEmpty(latest)) {
mv.setLatest(latest);
}
if (!Strings.isNullOrEmpty(release)) {
mv.setRelease(release);
}
mv.getVersions().addAll(Arrays.asList(versions));
return m;
}
示例2: buildSnapshotMavenMetadata
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
/**
* Build custom maven-metadata.xml according to a specific version.
*
* @param moduleInfo The original {@code ModuleInfo} to assemble the maven metadata according to the same
* gid,aid,and version, {@link org.apache.maven.artifact.repository.metadata.Versioning#setLastUpdatedTimestamp(java.util.Date)} is updated to now. and
* the build number and timestamp in the {@link org.apache.maven.artifact.repository.metadata.Snapshot} is set according to the name.
* @param fileName The file name
* @return The custom maven-metadata.xml
*/
public static Metadata buildSnapshotMavenMetadata(ModuleInfo moduleInfo, String fileName) {
Metadata metadata = new Metadata();
metadata.setGroupId(moduleInfo.getOrganization());
metadata.setArtifactId(moduleInfo.getModule());
metadata.setVersion(moduleInfo.getBaseRevision() + "-" + moduleInfo.getFolderIntegrationRevision());
Versioning versioning = new Versioning();
metadata.setVersioning(versioning);
versioning.setLastUpdatedTimestamp(new Date());
Snapshot snapshot = new Snapshot();
versioning.setSnapshot(snapshot);
snapshot.setBuildNumber(MavenNaming.getUniqueSnapshotVersionBuildNumber(fileName));
snapshot.setTimestamp(MavenNaming.getUniqueSnapshotVersionTimestamp(fileName));
if (ConstantValues.mvnMetadataVersion3Enabled.getBoolean()) {
SnapshotVersion snapshotVersion = new SnapshotVersion();
snapshotVersion.setUpdated(StringUtils.remove(snapshot.getTimestamp(), '.'));
snapshotVersion.setVersion(moduleInfo.getBaseRevision() + "-" +
moduleInfo.getFileIntegrationRevision());
//Should always be a pom, since this method is called only by PropertiesAddonImpl.assembleDynamicMetadata
snapshotVersion.setExtension(moduleInfo.getExt());
versioning.setSnapshotVersions(Lists.newArrayList(snapshotVersion));
}
return metadata;
}
示例3: buildReleasesMavenMetadata
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
public static Metadata buildReleasesMavenMetadata(String organization, String module,
SortedSet<String> sortedVersions) {
Metadata metadata = new Metadata();
metadata.setGroupId(organization);
metadata.setArtifactId(module);
if (!sortedVersions.isEmpty()) {
metadata.setVersion(sortedVersions.first());
Versioning versioning = new Versioning();
metadata.setVersioning(versioning);
versioning.setVersions(Lists.newArrayList(sortedVersions));
versioning.setLastUpdatedTimestamp(new Date());
versioning.setLatest(sortedVersions.last());
versioning.setRelease(sortedVersions.last());
}
return metadata;
}
示例4: createMetadata
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
private static Metadata createMetadata( Artifact artifact, boolean legacyFormat )
{
Snapshot snapshot = new Snapshot();
snapshot.setLocalCopy( true );
Versioning versioning = new Versioning();
versioning.setSnapshot( snapshot );
Metadata metadata = new Metadata();
metadata.setVersioning( versioning );
metadata.setGroupId( artifact.getGroupId() );
metadata.setArtifactId( artifact.getArtifactId() );
metadata.setVersion( artifact.getBaseVersion() );
if ( !legacyFormat )
{
metadata.setModelVersion( "1.1.0" );
}
return metadata;
}
示例5: createMetadata
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
private static Metadata createMetadata( Artifact artifact )
{
Versioning versioning = new Versioning();
versioning.addVersion( artifact.getBaseVersion() );
if ( !artifact.isSnapshot() )
{
versioning.setRelease( artifact.getBaseVersion() );
}
if ( "maven-plugin".equals( artifact.getProperty( ArtifactProperties.TYPE, "" ) ) )
{
versioning.setLatest( artifact.getBaseVersion() );
}
Metadata metadata = new Metadata();
metadata.setVersioning( versioning );
metadata.setGroupId( artifact.getGroupId() );
metadata.setArtifactId( artifact.getArtifactId() );
return metadata;
}
示例6: writeMetadata
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
private void writeMetadata(File folder, List<MavenCoordinates> coordinates) {
List<SnapshotVersion> snapshotVersions = getSnapshotVersionMetadata(coordinates);
if (!snapshotVersions.isEmpty()) {
Metadata metadata = new Metadata();
Versioning versioning = new Versioning();
versioning.setSnapshotVersions(snapshotVersions);
metadata.setVersioning(versioning);
metadata.setGroupId(coordinates.get(0).getGroupId());
metadata.setArtifactId(coordinates.get(0).getArtifactId());
metadata.setVersion(coordinates.get(0).getVersion());
writeMetadataFile(metadata, new File(folder, "maven-metadata.xml"));
}
}
示例7: createBaseMetadata
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
private Metadata createBaseMetadata( Artifact artifact )
{
Metadata metadata = new Metadata();
metadata.setArtifactId( artifact.getArtifactId() );
metadata.setGroupId( artifact.getGroupId() );
return metadata;
}
示例8: merge
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
/**
* Merges the "source" on top of "target" and returns the "target", the instances are mutated.
*/
private Metadata merge(final Metadata target, final Metadata source) {
// sanity checks
if (Strings.isNullOrEmpty(source.getGroupId())) {
source.setGroupId(target.getGroupId());
}
if (Strings.isNullOrEmpty(source.getArtifactId())) {
source.setArtifactId(target.getArtifactId());
}
// version differs: we do it "both ways" if set at all
if (Strings.isNullOrEmpty(target.getVersion())) {
target.setVersion(source.getVersion());
}
if (Strings.isNullOrEmpty(source.getVersion())) {
source.setVersion(target.getVersion());
}
checkArgument(
Objects.equals(nullOrEmptyStringFilter(target.getGroupId()), nullOrEmptyStringFilter(source.getGroupId())),
"GroupId mismatch: %s vs %s", target.getGroupId(), source.getGroupId());
checkArgument(
Objects
.equals(nullOrEmptyStringFilter(target.getArtifactId()), nullOrEmptyStringFilter(source.getArtifactId())),
"ArtifactId mismatch: %s vs %s", target.getArtifactId(), source.getArtifactId());
String targetVersion = nullOrEmptyStringFilter(target.getVersion());
String sourceVersion = nullOrEmptyStringFilter(source.getVersion());
// As per NEXUS-13085 allow this and log for support in case the resulting merge leads to downstream problems
if (!Objects.equals(targetVersion, sourceVersion)) {
log.warn("Merging with version mismatch for GA={}:{}, {} vs {}", target.getGroupId(), target.getArtifactId(),
targetVersion, sourceVersion);
}
mergePlugins(target, source);
mergeVersioning(target, source);
return target;
}
示例9: v
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
private Metadata v(final String groupId,
final String artifactId,
final String versionPrefix,
final String timestamp,
final int buildNumber)
{
final Metadata m = new Metadata();
m.setGroupId(groupId);
m.setArtifactId(artifactId);
m.setVersion(versionPrefix + "-SNAPSHOT");
m.setVersioning(new Versioning());
final Versioning mv = m.getVersioning();
mv.setLastUpdated(timestamp.replace(".", ""));
final Snapshot snapshot = new Snapshot();
snapshot.setTimestamp(timestamp);
snapshot.setBuildNumber(buildNumber);
mv.setSnapshot(snapshot);
final SnapshotVersion pom = new SnapshotVersion();
pom.setExtension("pom");
pom.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
pom.setUpdated(timestamp);
mv.getSnapshotVersions().add(pom);
final SnapshotVersion jar = new SnapshotVersion();
jar.setExtension("jar");
jar.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
jar.setUpdated(timestamp);
mv.getSnapshotVersions().add(jar);
final SnapshotVersion sources = new SnapshotVersion();
sources.setExtension("jar");
sources.setClassifier("sources");
sources.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
sources.setUpdated(timestamp);
mv.getSnapshotVersions().add(sources);
return m;
}
示例10: mavenMetadataToString
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
public void mavenMetadataToString() throws IOException {
Metadata metadata = new Metadata();
metadata.setArtifactId("theartid");
metadata.setGroupId("thegroupid");
String metadataStr = MavenModelUtils.mavenMetadataToString(metadata);
assertNotNull(metadataStr);
Metadata newMetadata = MavenModelUtils.toMavenMetadata(metadataStr);
assertEquals(newMetadata.getArtifactId(), metadata.getArtifactId());
assertEquals(newMetadata.getGroupId(), metadata.getGroupId());
}
示例11: createMetadata
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
private static Metadata createMetadata( Artifact artifact, boolean legacyFormat )
{
Metadata metadata = new Metadata();
if ( !legacyFormat )
{
metadata.setModelVersion( "1.1.0" );
}
metadata.setGroupId( artifact.getGroupId() );
metadata.setArtifactId( artifact.getArtifactId() );
metadata.setVersion( artifact.getBaseVersion() );
return metadata;
}
示例12: generateMavenMetadata
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
/**
* Generate the maven-metadata-local.xml for the given Maven <code>Artifact</code>.
*
* @param artifact the Maven <code>Artifact</code>.
* @param target the target maven-metadata-local.xml file to generate.
* @throws IOException if the maven-metadata-local.xml can't be generated.
*/
static void generateMavenMetadata(Artifact artifact, File target) throws IOException {
target.getParentFile().mkdirs();
Metadata metadata = new Metadata();
metadata.setGroupId(artifact.getGroupId());
metadata.setArtifactId(artifact.getArtifactId());
metadata.setVersion(artifact.getVersion());
metadata.setModelVersion("1.1.0");
Versioning versioning = new Versioning();
versioning.setLastUpdatedTimestamp(new Date(System.currentTimeMillis()));
Snapshot snapshot = new Snapshot();
snapshot.setLocalCopy(true);
versioning.setSnapshot(snapshot);
SnapshotVersion snapshotVersion = new SnapshotVersion();
snapshotVersion.setClassifier(artifact.getClassifier());
snapshotVersion.setVersion(artifact.getVersion());
snapshotVersion.setExtension(artifact.getType());
snapshotVersion.setUpdated(versioning.getLastUpdated());
versioning.addSnapshotVersion(snapshotVersion);
metadata.setVersioning(versioning);
MetadataXpp3Writer metadataWriter = new MetadataXpp3Writer();
Writer writer = new FileWriter(target);
metadataWriter.write(writer, metadata);
}
示例13: createSnapshotsMetadata
import org.apache.maven.artifact.repository.metadata.Metadata; //导入方法依赖的package包/类
private boolean createSnapshotsMetadata(RepoPath repoPath, ItemNode treeNode) {
if (!folderContainsPoms(treeNode)) {
return false;
}
List<ItemNode> folderItems = treeNode.getChildren();
Iterable<ItemNode> poms = Iterables.filter(folderItems, new Predicate<ItemNode>() {
@Override
public boolean apply(@Nullable ItemNode input) {
return (input != null) && MavenNaming.isPom(input.getItemInfo().getName());
}
});
RepoPath firstPom = poms.iterator().next().getRepoPath();
MavenArtifactInfo artifactInfo = MavenArtifactInfo.fromRepoPath(firstPom);
if (!artifactInfo.isValid()) {
return true;
}
Metadata metadata = new Metadata();
metadata.setGroupId(artifactInfo.getGroupId());
metadata.setArtifactId(artifactInfo.getArtifactId());
metadata.setVersion(artifactInfo.getVersion());
Versioning versioning = new Versioning();
metadata.setVersioning(versioning);
versioning.setLastUpdatedTimestamp(new Date());
Snapshot snapshot = new Snapshot();
versioning.setSnapshot(snapshot);
LocalRepoDescriptor localRepoDescriptor =
getRepositoryService().localOrCachedRepoDescriptorByKey(repoPath.getRepoKey());
SnapshotVersionBehavior snapshotBehavior = localRepoDescriptor.getSnapshotVersionBehavior();
String latestUniquePom = getLatestUniqueSnapshotPomName(poms);
if (snapshotBehavior.equals(SnapshotVersionBehavior.NONUNIQUE) ||
(snapshotBehavior.equals(SnapshotVersionBehavior.DEPLOYER) && latestUniquePom == null)) {
snapshot.setBuildNumber(1);
} else if (snapshotBehavior.equals(SnapshotVersionBehavior.UNIQUE)) {
// take the latest unique snapshot file file
if (latestUniquePom != null) {
snapshot.setBuildNumber(MavenNaming.getUniqueSnapshotVersionBuildNumber(latestUniquePom));
snapshot.setTimestamp(MavenNaming.getUniqueSnapshotVersionTimestamp(latestUniquePom));
}
if (ConstantValues.mvnMetadataVersion3Enabled.getBoolean()) {
List<SnapshotVersion> snapshotVersions = Lists.newArrayList(getFolderItemSnapshotVersions(folderItems));
if (!snapshotVersions.isEmpty()) {
versioning.setSnapshotVersions(snapshotVersions);
}
}
}
saveMetadata(repoPath, metadata);
return true;
}